Search This Blog

JavaFX: how to use ListProperty?

when adding element to ListProperty, like below:
ListProperty<String> members = new SimpleListProperty<String>();
members.add("John");
members.add("David");
it throws UnsupportedOperationException
java.lang.UnsupportedOperationException
  at java.util.AbstractList.add(AbstractList.java:148)
  at java.util.AbstractList.add(AbstractList.java:108)
  at java.util.AbstractCollection.addAll(AbstractCollection.java:334)
  at javafx.beans.binding.ListExpression.addAll(ListExpression.java:280)
The problem was that the ListProperty was not properly initialized. To make it work, see the following code
ObservableList<String> observableList = FXCollections.observableArrayList(new ArrayList<String>());
ListProperty<String> members = new SimpleListProperty<Priority>(observableList);
members.add("John");
members.add("David");







see also

目前看国内电视直播最好的办法:使用Bluestacks模拟器加《电视家》APP

  1. 安装Bluestacks安卓模拟器
  2. 下载《电视家直播》破解版,用Bluestacks打开,会自动安装。
  3. 启动Bluestacks运行《电视家直播》,一定要调成软解码。否则不停出现源失效错误。

See also

JavaFX: Add CSS to TreeTableView

treeTableView.getStylesheets().add("myStyles.css;");

JavaFX TreeTableView set font weight of a TreeTableColumn

Create a css file:
column.setStyle("-fx-font-weight: bold;");

Include javascript on github.com

Including raw github url of javascript in your web page will not work. You need to use some web site with CDN services to forward the request to github.
see this http://stackoverflow.com/questions/7180099/including-js-from-raw-github-com
or https://rawgit.com/

Make Papaya Javascript DICOM viewer work in JavaFX WebView

When loading Papaya Javascript DICOM/NIFTI Viewer in a JavaFX WebView, it failed with error message:
Papaya requires Safari version 6 or higher.
So I checked WebKit version of JavaFX 8 using the following code:
WebView web = new WebView();
System.out.println(web.getEngine().getUserAgent());
it shows the JavaFX 8 WebKit UserAgent information:
Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.19 (KHTML, like Gecko) JavaFX/8.0 Safari/538.19
According to Safari version history, Safari 6.0 is based on WebKit 536.25, while Webkit in JavaFX 8 is 538.19. WebKit in JavaFX 8 is above Safari 6.0. The problem is the browser detection in Papaya could not detect the version. So the work around is to modify the Papaya source code to accept JavaFX 8 WebKit agent.
  1. Check out Papaya js:
    git clone https://github.com/rii-mango/Papaya.git
  2. Edit src/js/utilities/platform-utils.js, insert the following code:
    papaya.utilities.PlatformUtils.checkForBrowserCompatibility = function () {
        if (navigator.userAgent.indexOf('JavaFX')>=0) {
            return null;
        }
       ... ... ...
    }
    
  3. Download and build Papaya-builder, then install it into Papaya/lib/:
    git clone https://github.com/rii-mango/Papaya-Builder.git
    cd Papaya-Builder
    ant
    cp build/papaya-builder.jar ../Papaya/lib/
    
  4. Build Papaya:
    cd Papaya
    ./papaya-builder.sh
    ls build/
    

Java: Open a url with default web browser

Open a web page with default web browser (from Java code):
try {
    java.awt.Desktop.getDesktop().browse(new URI("http://notepad2.blogspot.com.au/"));
} catch (Throwable e) {
    e.printStackTrace();
}

SIM Unlock Telstra ZTE MF60 WIFI modem

  1. Install ZTE MF60 Windows Driver on your Windows PC
  2. Install latest DC Unlocker
  3. Insert a non Telstra SIM, powered it on, and connect the ZTE MF60 WIFI modem to your Windows PC via USB
  4. Open DC-Unlocker as Administrator, select "ZTE Modems" then click "Detect" to detect the device
  5. Close DC Unlocker
  6. Run DCCrap to unlock the device (This will retain the IMEI & MAC address).

See also

JavaFX: load css from file

  • load from relative path:
     // the java class is in the same directory as the .css file.
    String css = getClass().getResource("MyApp.css").toExternalForm();
    scene.getStyleSheets().add(css);
    
  • load from absolute path:
    // the .css file is stored under <ROOT>/css/ directory.
    String css = getClass().getResource("css/MyApp.css").toExternalForm(); 
    scene.getStyleSheets().add(css);
    

JavaFX: Show grid lines of TreeTableView

  • Save the following to resources/MyApp.css:
    .tree-table-row-cell {
        -fx-background-color: -fx-table-cell-border-color, -fx-control-inner-background;
        -fx-background-insets: 0, 0 0 1 0;
        -fx-padding: 0.0em;
        -fx-text-fill: -fx-text-inner-color;
    }
    .tree-table-row-cell:selected {
        -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-focus-color;
        -fx-background-insets: 0, 1, 2;
    }
    
    .tree-table-row-cell:odd {
        -fx-background-color: -fx-table-cell-border-color, derive(-fx-control-inner-background,-5%);
        -fx-background-insets: 0, 0 0 1 0;
    }
    
    .tree-table-row-cell:selected:odd {
        -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-focus-color;
        -fx-background-insets: 0, 1, 2;
    }
    
  • In your Java class, add the css to a scene.
    String css = getClass().getResource("/resources/MyApp.css").toExternalForm();
    scene.getStyleSheets().add(getClass().getResource(cs);
    

Java: Convert image to png format

  • Make sure you have JAI & ImageIO plugins installed. Recommend to use standlone/independent jai-imageio-core from github.
  • The example code:
    • import java.awt.image.BufferedImage;
      import java.io.File;
      import javax.imageio.ImageIO;
      
      public static void main(String[] args) {
      
        ImageIO.scanForPlugins();
      
        // read a tiff image
        BufferedImage bufferedImage = ImageIO.read(new File("c:/tmp/1.tif"));
      
        // write back to another file in png format
        ImageIO.write(bufferedImage, "png", new File("c:/tmp/1.png"));
      
      }
      

SSH access to Github from multiple accounts

  • Generate SSH Keys:
    ssh-keygen  -t rsa -b 4096 -C "email@personal.com" -f ~/.ssh/id_rsa_personal
    ssh-keygen  -t rsa -b 4096 -C "email@work.com" -f ~/.ssh/id_rsa_work
    
    The two commands above generate two key pairs: id_rsa_personal/id_rsa_personal.pub, id_rsa_work/id_rsa_work.pub
  • Add SSH Keys to your github accounts.
    • Add id_rsa_personal.pub to your personal github account:
      • Login to your github
      • Go to Settings -> Add SSH Keys
      • Copy of the content of id_rsa_personal.pub to the key field
      • Click Add Key
    • Add id_rsa_work.pub to your github account for work:
      • Login to your github
      • Go to Settings -> Add SSH Keys
      • Copy of the content of id_rsa_work.pub to the key field
      • Click Add Key
  • Create a file: ~/.ssh/config and add:
    • Host personal
         HostName github.com
         User git
         IdentityFile ~/.ssh/id_rsa_personal
      
      Host work
         HostName github.com
         User git
         IdentityFile ~/.ssh/id_rsa_work
      
  • Update stored identities:
    • ssh-add -D
      ssh-add id_rsa_personal
      ssh-add id_rsa_work
      
  • Test
    • ssh -T personal
      Hi githubPersonal! You've successfully authenticated, but GitHub does not provide shell access.
      $ ssh -T work
      Hi githubWork! You've successfully authenticated, but GitHub does not provide shell access.
      

Github: Use Access Token to authenticate over HTTPS

  • Login to Github
  • If you have not enabled Two-factor authentication, you need to enable it:
    • Go to "Settings" -> "Security"
  • Generate Personal Access Tokens:
    • Go to "Settings" -> "Personal Access Tokens"
  • Click "Generate new token" at the top right corner.
  • Remember/Copy the token.
  • Insert the token to your repository url:
    https://<token>@github.com/owner/repo.git
  • Now you can push to the repository without typing username & password.

Javascript inheritance: A simple example

var Person = function(name) {
    this.name = name;
}

Person.prototype.walk = function() {
    alert(this.name + ' is walking.');
}

var Driver = function(name) {
    Person.call(this,name);
}

Driver.prototype = Object.create(Person.prototype);

Driver.constructor = Driver;

Driver.prototype.drive = function(){
    alert(this.name + ' is driving.');
}

var dave = new Person('David');
dave.walk();

var john = new Driver('John');
john.drive();

Embed Youtube Video in a doku wiki page

Use the syntax below:
{{http://www.youtube.com/v/VIDEO_ID?.swf?640×360}}
where you need to replace VIDEO_ID with your actual video id, and 640x360 to the width x height you want.

Firefox: Disable mixed content blocking

Firefox blocks the mixed content by default. You can click the little shield icon at the left end of the address bar, then select "Disable protection...", to unblock the web site. However, Firefox does not remember it. Next time you open the web site, you need to go through the same process to unblock it. It is pretty annoying.

You can disable mixed content blocking by
  • Option 1: editing about:config
    • enter about:config in address field.
    • search for security.mixed
    • select security.mixed_content.block_active_content and set it false
  • Option 2: install Toggle Mixed Active Content addon
    • After install the addon, you will see a button with green capital A as icon. Color green means the blocking is enabled. Toggle the button to disable the blocking (the color of the icon will become red: means blocking is disabled.)

Note:

The above options disabled mixed content blocking on all the web sites. It downgrades the security a little bit. The ideal solution will be a whitelist of sites with mixed content in FireFox. We can vote for whitelisting mix-content sites function in Firefox.

Re-enable Windows XP update by applying a registry patch

  • Save the following text:
    Windows Registry Editor Version 5.00
    [HKEY_LOCAL_MACHINESYSTEMWPAPosReady]
    "Installed"=dword:00000001
    
    into a text file named xp.reg
  • double click the reg file to apply the patch.

Java: convert int to unsigned

int toUnsigned(short i){
    return Short.toUnsignedInt(); // i&0xffff;
}

long toUnsigned(int i){
    return Integer.toUnsignedLong(); // i&0xffffffffl;
}

Java: Regular expression to match dot separated numbers

The dot separated values look like below:
1
1.2.3
1.2.3.4.5
The regular expression to match: "^\\d+(\\d*.)*\\d+$"

Java code:
System.out.println(Pattern.matches("^\\d+(\\d*.)*\\d+$", "1")); // true
System.out.println(Pattern.matches("^\\d+(\\d*.)*\\d+$", "1.2.3")); // true
System.out.println(Pattern.matches("^\\d+(\\d*.)*\\d+$", "1.2.a")); // false
System.out.println(Pattern.matches("^\\d+(\\d*.)*\\d+$", "1.2.3.")); // false

Java: Check if a year is leap year

public static boolean isLeapYear(int year) {
    assert year >= 1583; // not valid before this date.
    return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
}
public static boolean isLeapYear(int year) {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.YEAR, year);
    return cal.getActualMaximum(DAY_OF_YEAR) > 365;
}

Bash: for loop

#!/bin/bash

# backup IFS
IFSBAK=$IFS
IFS=$(echo -en "\n\b")

for f in $(ls)
do
    echo "$f"
done

# restore IFS
IFS=$IFSBAK

几个标点符号的英文翻译

小括号( ) parentheses
中括号[ ] square brackets
大括号{ } curly brackets
尖括号< > angle brackets
: colon
, comma
- hyphen
- - - dash
! Exclamation mark
; semicolon
/ slash
? question mark
. full stop/period

Github: fork a repository and sync the fork

  1. Fork a repository
    • Clone the repository:
      git clone https://github.com/ORIGINAL_OWNER/ORIGINAL_REPO.git
    • Add the original repository as upstream:
      git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPO.git
    • Check the status:
      git remote -v
      You will see:
      # origin    https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
      # origin    https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
      # upstream  https://github.com/ORIGINAL_OWNER/ORIGINAL_REPO.git (fetch)
      # upstream  https://github.com/ORIGINAL_OWNER/ORIGINAL_REPO.git (push)
      
  2. Sync the fork with upstream(original):
    • Fetch the branches and their respective commits from the upstream repository:
      git fetch upstream
    • Check out your fork's local master branch:
      git checkout master
    • Merge the changes from upstream/master into your local master branch. This brings your fork's master branch into sync with the upstream repository, without losing your local changes.
      git merge upstream/master
    • Push local repository:
      git push --tags

Configure gwt-maven-plugin to start classic DevMode instead of SuperDevMode in GWT 2.7.0

In the pom.xml, pluginManagement -> plugins:
<pluginManagement>
    
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <goals>
               <goal>run</goal>
            </goals>
            <configuration>
                <extraJvmArgs>-Xmx1024m</extraJvmArgs>
                <superDevMode>false</superDevMode>
                <noServer>true</noServer>
            </configuration>
        </plugin>
    </plugins>
</pluginManagement>
Note:noServer is set true which will not start the embedded jetty web server.
For more details about the configuration options for gwt:run goal, run the following command:
mvn help:describe -Dplugin=org.codehaus.mojo:gwt-maven-plugin -Dgoal=run -Ddetail

Maven: no POM for for org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 is missing, no dependency information available

Solution:
cd /tmp
mvn archetype:generate -DgroupId=org.eclipse.m2e -DartifactId=lifecycle-mapping -Dversion=1.0.0 -DarchetypeArtifactId=maven-archetype-mojo
cd lifecycle-mapping
mvn clean install
mvn install:install-file -Dfile=target/lifecycle-mapping-1.0.0.jar -DpomFile=pom.xml -DcreateChecksum -DlocalRepositoryPath=/path/to/localMavenRepo

Maven Eclipse set compiler JDK compliance level

The maven project/module created in Eclipse set JAVA 1.5 as the default. You cannot change it via Eclipse project settings (as it will be reverted back to 1.5) when you run Maven -> Update Project. To solve this, you can add the following to the pom.xml:
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>
Or, if you have hierarchical project with modules, you can put it into pluginManagement of the parent project's pom.xml:
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
All the descendant modules will inherit the compiler settings from the parent.

NOTE:

In Eclipse, if the project packaging is pom the compiler settings will not get updated using the above. You will need to change packaging to jar then Update the Maven projects. You can revert back to pom after the compiler settings has been changed.

Install pixelmed jar files into local maven repository

  • The script to install the pixelmed jar files to local maven repository:
    #!/bin/bash
    
    repo=/path/to/mvn-repo
    dir=/path/to/pixelmed
    
    name=pixelmed-codec
    version=20141206
    mvn install:install-file \
        -Dfile=${dir}/pixelmed_codec.jar \
        -DgroupId=com.pixelmed \
        -DartifactId=pixelmed-codec \
        -Dname=pixelmed_codec.jar \
        -Dversion=${version} \
        -Dpackaging=jar \
        -DperformRelease=true \
        -DcreateChecksum=true \
        -DgeneratePom=true \
        -DlocalRepositoryPath=${repo}
    
    name=pixelmed-aiviewer
    version=20150512
    mvn install:install-file \
        -Dfile=${dir}/aiviewer.jar \
        -DgroupId=com.pixelmed \
        -DartifactId=pixelmed-aiviewer \
        -Dname=aiviewer.jar \
        -Dversion=${version} \
        -Dpackaging=jar \
        -DperformRelease=true \
        -DcreateChecksum=true \
        -DgeneratePom=true \
        -DlocalRepositoryPath=${repo}
    
    name=pixelmed
    version=20150512
    mvn install:install-file \
        -Dfile=${dir}/pixelmed.jar \
        -DgroupId=com.pixelmed \
        -DartifactId=pixelmed \
        -Dname=pixelmed.jar \
        -Dversion=${version} \
        -Dversion=${version} \
        -Dpackaging=jar \
        -DperformRelease=true \
        -DcreateChecksum=true \
        -DpomFile=/path/to/pixelmed.pom.xml \
        -DlocalRepositoryPath=${repo}
    
  • The pom.xml for pixelmed.jar
    <?xml version="1.0" encoding="UTF-8"?>
    <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.pixelmed</groupId>
      <artifactId>pixelmed</artifactId>
      <version>20150512</version>
      <description>PixelMed Java DICOM library.</description>
      <dependencies>
        <dependency>
          <groupId>javax.jmdns</groupId>
          <artifactId>jmdns</artifactId>
          <version>3.4.1</version>
        </dependency>
        <dependency>
          <groupId>org.hsqldb</groupId>
          <artifactId>hsqldb</artifactId>
          <version>2.3.2</version>
        </dependency>
        <dependency>
          <groupId>java3d</groupId>
          <artifactId>vecmath</artifactId>
          <version>1.3.1</version>
        </dependency>
        <dependency>
          <groupId>commons-net</groupId>
          <artifactId>commons-net</artifactId>
          <version>3.3</version>
        </dependency>
        <dependency>
          <groupId>commons-codec</groupId>
          <artifactId>commons-codec</artifactId>
          <version>1.10</version>
        </dependency>
        <dependency>
          <groupId>org.apache.commons</groupId>
          <artifactId>commons-compress</artifactId>
          <version>1.9</version>
        </dependency>
      </dependencies>
    </project>
    

Python: string comparison == or is

Use == when comparing values and is when comparing identities.
>>> a = 'abc'
>>> b = ''.join(['a', 'b', 'c'])
>>> a == b
True
>>> a is b
False

see also

Python: remove an item from list while iterating the list

list[:] = [item for item in list if match(item)]
The above code removes the matching items in the list without constructing a new list, therefore, the references to the list remain valid.

see also

Python: remove dictionary items while iterating it

  • Delete the matching items based on the keys:
    for k in dict.keys():
        if k == 'yes':
        del dict[k]
    
  • Delete the matching items based on the values:
    for k, v in dict.items():
        if v == 3:
            del dict[k]
    

Python: empty a list

del list[:]
list[:]=[]

Eclipse: count the number of lines

  • Search -> File...
  • Check "Regular Expression" and enter "Containing text": ^.*$
  • Enter "File name patterns": *.java
  • Click "Search" button
  • In the result "Search" tab, the number of matches is the number of lines (exclude blank lines)

【转帖】迅雷、快车、旋风链接地址加密解密方法

原帖: http://blog.csdn.net/smfwuxiao/article/details/6094286

迅雷地址和快车地址的加密方式很简单,其实都是用的Base64加密方式,只不过有一点点的小改动而已。

1、迅雷
迅雷链接地址转换原理是在地址的前方和后方加入两个字母AA、ZZ,然后再进行Base64加密,再加上Thunder://这个专用链接标识,从而转换成迅雷的专用地址。

例如:

原链接为:http://www.forece.net/win7.rar

在原地址前面加”AA”,后面加”ZZ”(注:不包括引号),地址变为
AAhttp://www.forece.net/win7.rarZZ

此地址base64编码为
QUFodHRwOi8vd3d3LmZvcmVjZS5uZXQvd2luNy5yYXJaWg==

加入迅雷专链标识,即在上地址前加thunder://,即
thunder://QUFodHRwOi8vd3d3LmZvcmVjZS5uZXQvd2luNy5yYXJaWg==

2、网际快车
网际快车的链接地址转换原理和迅雷的类似,只不过是在地址前后加上[FLASHGET],经过Base64加密,然后在地址前加flashget://这个快车专用链接标识,最后还需要加一个标识符(&符号),符号任意,我一般就加我的名字(&forece),这样就可以将普通http地址转换成快车的地址了。

例如:

原链接为:http://www.forece.net/win7.rar

在原地址前后都加上”[FLASHGET]“(注:不包括引号),地址变为

[FLASHGET]http://www.forece.net/win7.rar[FLASHGET]

此地址base64编码为

W0ZMQVNIR0VUXWh0dHA6Ly93d3cuZm9yZWNlLm5ldC93aW43LnJhcltGTEFTSEdFVF0=

加上快车专链标识和结尾符号,即在上地址前加flashget://,结尾加&forece,即

flashget://W0ZMQVNIR0VUXWh0dHA6Ly93d3cuZm9yZWNlLm5ldC93aW43LnJhcltGTEFTSEdFVF0=&forece

“&符号”,符号怎么得出我也不清楚,只是看网上别人这么写的,至今无人报错。

3、QQ旋风
QQ旋风的地址转换相对就简单多了,将原地址直接base64编码加密就可以了,然后加上标识符qqdl://即可。

例如:

原链接为:http://www.forece.net/win7.rar

此地址base64编码为

aHR0cDovL3d3dy5mb3JlY2UubmV0L3dpbjcucmFy

再加上旋风专链标识,在上地址前加qqdl://,即

qqdl://aHR0cDovL3d3dy5mb3JlY2UubmV0L3dpbjcucmFy

这样,普通的http地址就可以轻松的转换成快车,迅雷,旋风的地址了。相反,解密只要将过程反推即可。同样还是利用Base64加密,解密工具。迅雷地址和快车地址的加密方式很简单,其实都是用的Base64加密方式,只不过有一点点的小改动而已。


1、迅雷
迅雷链接地址转换原理是在地址的前方和后方加入两个字母AA、ZZ,然后再进行Base64加密,再加上Thunder://这个专用链接标识,从而转换成迅雷的专用地址。

例如:

原链接为:http://www.forece.net/win7.rar

在原地址前面加”AA”,后面加”ZZ”(注:不包括引号),地址变为
AAhttp://www.forece.net/win7.rarZZ

此地址base64编码为
QUFodHRwOi8vd3d3LmZvcmVjZS5uZXQvd2luNy5yYXJaWg==

加入迅雷专链标识,即在上地址前加thunder://,即
thunder://QUFodHRwOi8vd3d3LmZvcmVjZS5uZXQvd2luNy5yYXJaWg==

2、网际快车
网际快车的链接地址转换原理和迅雷的类似,只不过是在地址前后加上[FLASHGET],经过Base64加密,然后在地址前加flashget://这个快车专用链接标识,最后还需要加一个标识符(&符号),符号任意,我一般就加我的名字(&forece),这样就可以将普通http地址转换成快车的地址了。

例如:

原链接为:http://www.forece.net/win7.rar

在原地址前后都加上”[FLASHGET]“(注:不包括引号),地址变为

[FLASHGET]http://www.forece.net/win7.rar[FLASHGET]

此地址base64编码为

W0ZMQVNIR0VUXWh0dHA6Ly93d3cuZm9yZWNlLm5ldC93aW43LnJhcltGTEFTSEdFVF0=

加上快车专链标识和结尾符号,即在上地址前加flashget://,结尾加&forece,即

flashget://W0ZMQVNIR0VUXWh0dHA6Ly93d3cuZm9yZWNlLm5ldC93aW43LnJhcltGTEFTSEdFVF0=&forece

“&符号”,符号怎么得出我也不清楚,只是看网上别人这么写的,至今无人报错。

3、QQ旋风
QQ旋风的地址转换相对就简单多了,将原地址直接base64编码加密就可以了,然后加上标识符qqdl://即可。

例如:

原链接为:http://www.forece.net/win7.rar

此地址base64编码为

aHR0cDovL3d3dy5mb3JlY2UubmV0L3dpbjcucmFy

再加上旋风专链标识,在上地址前加qqdl://,即

qqdl://aHR0cDovL3d3dy5mb3JlY2UubmV0L3dpbjcucmFy

这样,普通的http地址就可以轻松的转换成快车,迅雷,旋风的地址了。相反,解密只要将过程反推即可。同样还是利用Base64加密,解密工具。

HTML: read only checkbox


  • Method 1:
    <input name="test" type="checkbox" disabled checked/>
    
    Cons: disabled checkbox doesn't send value via POST data
  • Method 2:
    <input name="test" type="checkbox" checked onclick="return false;"/>
    
    Cons: does not work for double-clicks in IE.
  • Method 3:
    <input name="test" type="checkbox" checked onclick="this.checked=!this.checked;"/>
    
    Cons: does not work for double-clicks in IE.
  • 转:北京大学法学院2013级本科生《刑法分论》期中案例:爱的春夏秋冬(车浩)

    北京大学2013级本科生《刑法分论》期中考试试题
    兄弟反目,姐妹隙墙。为情还债,烈女委身权贵后跳楼自尽;为爱复仇,渣男步步为营中深陷情网。这,究竟是人性的缺失还是道德的沦丧?刑法会给你答案…
    A市富豪陈大山与1997年创立经营大山集团,并育有两子两女。大女儿陈春,二女儿陈夏,大儿子陈秋,小儿子陈冬。陈春大学毕业后进入大山集团,深的陈大山信任,被任命为总经理。陈冬作为公司副总,协助陈春处理集团事务。陈夏自高中起即被陈大山送去美国留学。陈秋在国企顺达商贸公司采购部工作。
    
    大山集团自水果起家,但陈大山希望集团能够实现多元化经营。为此,陈春从2003年开始努力拓展医药市场,投入巨额资金研发治疗头痛的新药“真灵”。由于技术底子薄弱,屡试不灵,为了避免前期投入打水漂,又考虑到虽然成分不符但实验结果对人体无害,于是陈春同意了技术部门的建议,将试验的失败品包装成治疗脚臭的“真香”出售。万万没想到“真香”的市场反应出奇的好,实效远远超出了一般的脚臭药。陈大山大喜,决定成立专门的制药厂,由陈冬负责,扩大生产。为了筹措资金,陈冬决定以投资入股的方式向集团内部员工集资。在说明大会上,陈冬并没有披露技术部门尚未搞清楚为何本用于治疗头痛的“真灵”对于脚臭有奇效这一秘密。由于市场热卖、前景可观,公司员工纷纷出资并介绍亲友加入。陈冬对此乐见其成,制药厂筹得巨款后购入国外生产线进行生产。
    
    2005年3月,陈大山决定由陈春负责将企业上市。期间,出现了个别患者怀疑因服用“真香”而出现脚部萎缩的问题,但陈春认为这只是个例,在招股说明书回避了“真香”面临的药理风险问题,公司顺利上市。两年后,关于“真香”的投诉越来越多,2007年6月,某国际公共卫生组织官员何番带队到大山集团调查,发现公司秘书米兰竟是昔日同窗。陈春了解两人关系后,向米兰开出当月十倍工资奖金,要求米兰与何番发生关系,米兰为了帮助男友还清赌债而同意。何番与米兰春风一度后又提出保持长期性关系,米兰拒绝,何番恼怒,表示要深查大山集团。陈冬找到米兰,以偷拍的米兰与何番的床照曝光相威胁,逼迫米兰满足何番的要求。无奈之下,米兰又多次与何番发生关系,终因觉得对不住男友而自杀。何番于2007年8月离开大山集团,调查中止。
    
    米兰的男友贺石得知女友自杀后大恸,深夜借酒浇愁,大醉后驾驶摩托车在环路上高速飙车,与刚刚回国驾车的陈夏相撞后受轻伤,被陈夏送进医院。陈夏为贺石的颓废气质所迷,整日纠缠,并提出可介绍贺石进入大山集团。贺石假意接受陈夏表白,并加入大山集团,其实是想找到米兰自杀的真正原因。陈夏回国后发现,因为陈大山信任陈春让其主持集团业务,导致陈秋与陈春一直关系不和。陈夏劝说陈秋应该努力运用在国企采购部门的权力,帮助家族企业发展,以取得父亲的信任。陈秋深以为然,在陈夏的建议下,2007年10月,陈秋代表顺达公司以高价从大山集团订购了1000吨水果。12月,在对“真香”的药理风险毫不知情的情况下,陈秋又与大山集团签订了大批量的“真香”采购合同,准备外销。由于顺达公司从大山集团采购的水果进价太高,销路阻滞,大部分水果烂在仓库中。而“真香”被出口到非洲后,部分黑人短跑健将因服用该药而脚部萎缩,严重影响了奥运会成绩,顺达公司为此支付大额赔款。2008年11月陈秋被国企开除,回到了大山集团。
    
    陈春、陈夏、陈秋和陈冬兄弟姐妹四人,在公司内部展开各种明争暗斗。陈春为了报复陈夏和陈秋的结盟,遂主动勾引贺石。贺石自己在外开设了一家大通公司,想通过陈春与大山集团签订合同,陈春怀疑大通公司的实力,贺石伪造了虚假的产权证明作为担保,合同签订后贺石又将业务转手给他人,虽然最后完成了订单,但是陈春发现产权证明为假,不想再与大通合作。然而,此时的陈春已经在与贺石的感情中难以自拔,在贺石表示要自残的威胁下,陈春只得同意继续与大通公司签单。陈夏发现贺石与陈春的关系后大受打击,决定报复陈春。2009年5月,陈夏将陈春带回家的公司核心技术信息外泄与大山集团有竞争关系的其他公司。陈大山发现陈春与缺乏实力的大通公司签约,加之商业秘密外泄,对陈春非常失望,暂停陈春在公司的职务。贺石渐渐喜欢上了陈夏,遂向陈春提出分手,陈春急于挽留,向贺石透露大山集团正在与外资合作准备资产重组的消息。2010年4月,贺石在大山集团股票停售前买入500万元。
    
    2011年2月,大山集团重组计划失败,股票复牌后不涨反跌,大山集团开始走下坡路。陈春酒后说出了“真香”的药理风险和米兰的自杀真相。贺石联系何番,以米兰之死相威胁,要求何番重新调查“真香”。2012年5月,何番再次回到大山集团,深入调查后表示,“真香”危及人体健康的风险不是偶然性的而是对神经系统带有难以逆转的伤害。陈大山得知调查结论后即为震惊一方面以提供给何番1%的大山集团的“干股”为代价,要求何番不公布调查结论,另一方面重新重用陈春,让其加大“真香”的销售速度,打算在该品牌破产前最后敛财。陈春掌权后最后提出与贺石复合。贺石想到米兰的死,决定报复陈春,在灌醉陈春后唆使何番冒充自己与陈春上床,陈春在醉酒状态下误以为何番是贺石,于是与何番发生关系,醒后后悔不已。贺石对其嘲弄挖苦,陈春冲动之下跳楼,未死但摔成植物人状态。
    
    2013年8月,贺石到医院看望陈春时心生悔意,觉得不如让陈春早日结束这种虽生犹死的状态,于是拔掉陈春的输液管,恰好此时,陈大山和陈冬到医院看望陈春,发现后赶紧制止。陈大山、陈冬与贺石三人厮打在一起,陈大山在被贺石集中鼻部后流血,昏倒在地,经抢救无效死亡(鉴定结论:陈大山存在高血压性并冠状动脉粥样硬化应心脏病,因纠纷后情绪激动、头面部受外力作用等导致机体反激反映,促发有病变的心脏骤停而死亡。)。陈冬冲出医院追打贺石,贺石跑到马路对面出言辱骂陈冬,大叫:“有种就追过来”,陈冬被激怒,不顾红灯横穿马路时发生车祸,被撞成重伤。(经交管部门认定,司机对此事故不负任何责任。)
    
    2013年12月,陈秋主掌大山集团,聘请何番担任顾问。贺石召开新闻发布会,将“真香”的药物风险全部公开。大山集团四面楚歌。2014年3月,陈秋不得已申请企业破产,清算组进驻期间,陈秋与何番合谋,伪造了一份大山集团亏欠某国际公共卫生组织500万元的债务。事发后陈秋、何番被警方带走。贺石得知陈夏要出国,遂购买同航班机票,在飞机上向陈夏忏悔和告白,但是,因家破人亡而心灰意冷的陈夏,觉得一切因果皆出于贺石与自己的相遇,万念俱灰之下临时起意,谎称身上有炸药,逼迫机长飞往太平洋上某个小岛,飞机改线后失联。
    
    问案中人的刑事责任。
    

    转:北京大学法学院2013级本科生《刑法分论》期末案例:爱的东南西北(车浩)

    北京大学法学院2013级本科生《刑法分论》期末案例
    
      考试时间:四小时
    
      考试方式:开卷
    
      考查范围:刑法分论
    
      出题老师:车浩
    
      答题要点:简要说明案中人的犯罪及理由,并进一步分析其中可能存有的争议之处,题中时间系联系案情需要,答题时以现行刑法为依据,无需考虑效力问题。
    
      1977年冬天,中国恢复高考,周小东、吴小南、郑小西和王小北经过激烈竞争,考入西京大学法律系。1978年春天入校,被分至同一间宿舍。四人志向各异,但都珍惜机遇,发奋读书,同窗四载,互相砥砺,结下了深厚友谊。1982年大学毕业,周小东被分配至西京省政府办公厅调研室工作,郑小西留校任教,王小北被分配至市检察院,吴小南则阴差阳错进入国有钢厂。四人约定各自努力奋斗,每十年一聚。
    
      转眼几年过去,吴小南成为钢厂副厂长。1985年3月,西京著名“倒爷”苏三找到吴小南,请其帮忙以统配价格批100吨钢材,吴小南看在发小的情面上,为其弄到批条。一个月后,苏三到吴小南家塞给其2万元表示感谢。吴小南感到意外,几番推辞之后收下,由此开始不满稳定的收入,希望改变现状。1987年,全国兴起承包制,吴小南帮助苏三取得钢厂承包权,协定每年上缴国家200万元,超额利润五五分成。一年之后,企业盈利400万元,苏三与吴小南商议,谎称盈利300万元,上缴200万元后再分给国家50万元,实际余利由二人均分。在吴小南的支持下,苏三以此方法顺利承包钢厂五年。
    
      1992年2月,邓小平发表南巡讲话。国发印务公司试点股份制改革,吴小南调任该公司经理。上任伊始,即以苏三名义成立另一家印刷厂,将国发公司的一部分业务转介给该印刷厂,吴获利数十万元。半年后,吴小南对国企再无留恋,辞去公职,下海创业。凭借多年经验和人脉,迅速建立起多元化业务的小南集团。1992年12月,意气风发的吴小南召集大学同学十年聚会。在聚会上,吴小南见到了毕业时分手的大学恋人莫小君,知悉莫小君已嫁给郑小西,但因性格不合常年冷战。此次聚会使得吴莫两人旧情复燃,也让一直暗恋莫小君的王小北黯然神伤。
    
      1993年1月,莫小君向郑小西提出离婚,郑不同意。莫小君决然离开,搬至吴小南住处,两人开始同居。郑小西深受刺激,认为莫是嫌自己清贫,此时正值海南房地产大热,遂决定也下海实践一把,于是找到调任市发改委的周小东,谎称父母手术需要钱,向周借款。2月,周小东从单位转出30万元给郑,嘱其三个月内归还。郑小西携款赴海南炒楼。1993年6月,海南房地产泡沫破灭,郑小西全部赔光,无奈之下,只得向周小东谎称自己已备好还款,但遭遇窃贼,被洗劫一空。周看出郑撒谎,但基于多年同学感情不忍揭穿。吴小南得知此事,主动找到周小东还款解围,但叮嘱周对郑保密。
    
      1997年香港回归,时任副市长的周小东赴港参访,结识了亚姐季军乐菲并为之倾倒。乐菲的真实身份是P国间谍,与周小东春风一度后,以帮助家族企业去内地投资为由,向周小东索求关于西京省改革的国家秘密,周小东百依百顺,向其提供。1997年10月,乐菲随周小东回到西京后,周小东介绍乐菲到小南集团工作,虽不上班但领取薪酬。半年后,周小东始发觉乐菲身份,吃惊之下找吴小南商量,吴建议周除掉乐菲,消除仕途后患。1998年6月,周小东在递给乐菲的酒中下毒,乐菲昏迷后,周误以为乐菲已死,遂找来吴小南处理后事。吴小南开车将乐菲拉到郊外埋尸,乐菲最终因窒息而死。吴小南的埋尸过程碰巧被和检察院同事一起郊游的王小北发现,但他没有惊动吴小南,反而找借口劝同事换了路线,离开此地。
    
      此事过后,周小东不近女色,全心工作,很快升任市长。2001年中国入世,一系列改革措施出台。周小东为吴小南提供信息,帮助其抢得与海外企业合作先机。在周的帮助下,吴用集团大厦作抵押,虽超出价值向数家银行重复担保,仍取得数十亿贷款,偿清借贷后企业加速发展,成为西京商业巨头。2002年12月,吴小南召集毕业二十年聚会。自海南事件后回归高校、已成为学界名流的郑小西,见到吴小南和莫小君一起出席,心情郁闷,借酒消愁。吴小南也感到难以面对昔日好友。王小北提议,让两人像大学时那样打架出气,吴小南表示,只要郑小西能原谅自己,甘愿被打。郑小西借着酒劲,痛殴吴小南,吴不还手被打成骨折(轻伤)。郑小西却声称不宽恕,周看不下去,遂道出吴当年帮郑还款一事,郑小西懊恼离去,放言再不参加同学聚会。
    
      2003年3月,SARS惊现西京城。吴小南决定联合另一商界巨头陈大山,开发研制抗SARS新药。小南集团和大山集团联手入主已经上市的某医药企业,分别为第一和第二大股东。后因争夺董事会席位,双方翻脸成仇。吴小南通过媒体,夸大甚至捏造大山集团生产的“真香”药品存在致命风险的消息。陈大山请示市委书记赵丰收(大山集团的后台)后,抛出小南集团为周小东代持部分股权的重磅炸弹。
    
      2008年1月,吴小南被立案调查并采取强制措施,莫小君找到周小东求助。周小东决定兵行险着,设计扳倒赵丰收。2008年5月,莫小君委托律师黄九以辩护人的身份会见吴小南,暗示其可暂作出不利于周小东的口供,伺机再翻供。同时,周小东授意莫小君带着录音笔亲自去找赵丰收,佯言吴愿意倒戈出卖周小东,并以奥运场馆附近的豪宅相赠,作为投靠赵丰收的投名状。赵丰收已经通过公安局了解到了吴小南的口供变化,遂信以为真,接受了房间钥匙。又为莫小君姿色吸引,遂以保吴小南平安为砝码,向莫提出性要求。莫小君逼不得已只好答应,并订好一家酒店。赵丰收和莫小君发生关系后颇为得意,夸耀自己在西京的势力范围,以及陈大山为其在P国购买别墅等隐私。整个过程都被周小东事前布置好的摄像机录下,莫小君将录音和视频寄到西京省纪委。2010年1月,赵丰收被“双规”后移交检察院,由于赵丰收供述反复,已经成为副检察长的王小北指令下属用手铐将赵的手和脚铐在一起,保持该姿势一夜之后,赵丰收全部招供。
    
      王小北明知吴小南可能涉嫌犯罪,但基于同学感情,决定对吴小南做不起诉处理。2012年5月,周小东升任西京省副省长,作为赵丰收的老领导,西京省委书记孙天宇知道赵的落马与周有关,且听闻周昔日与某亚姐的交往,决定通过吴小南彻查周小东。2012年10月,小南集团被人举报卷入“地沟油”事件,吴小南再次被捕。公安局刑警李大和王二奉命到吴小南家搜查。因西京堵车,两人坐地铁前往,不料被4号线上的惯偷钱四盯上,李大放在衣服里的200元钱和搜查证被偷走。两人到了吴家后,莫小君要求出示其证件,两人这才发现搜查证丢失,莫小君怀疑其身份,遂取水果刀威胁和阻拦,李大强行制服莫小君,王二进入屋内搜查,最后取走莫小君的笔记本电脑等物品。
    
      莫小君找到公安局的朋友江五,想将扣押财物取回。江五疏通关系未成功,只得将部分扣押物品偷出,准备第二天交给莫。回家后,江五又临时起意,将笔记本留给儿子江小五使用,把其他物品交给莫小君时,声称笔记本暂未发现,江小五在将笔记本拿给邻居侯六修理时,被侯六发现了电脑内隐藏的赵丰收和莫小君的性爱视频,侯六查到该视频的男女身份后,给莫小君打电话,要求莫小君带5万元现金换回视频。莫小君被迫答应,带钱到侯六家后,却被人从背后打昏后强奸。
    
      莫小君醒后报案,案件被移送至检察院,王小北闻知莫小君受辱,又见侯六拒不承认,难耐怒火,在讯问侯六的过程中使用暴力,致侯死亡。检察长曹明向来器重王小北,为了保护他,让法医白七开了侯六心梗突发的假证明,按照一般违纪行为对王小北予以降职处分。两个月后,网上忽现当年莫小君和赵丰收的性爱视频,经查,系江小五放到色情网站“天国乐土”上,且已通过会员收费获利数万元。江小五在被捕讯问中,坦白自己当初打昏并强奸莫小君的经过。王小北这才知道冤枉了侯六,心灰意冷,自觉在机关内再难容身,遂辞去公职,下海做了律师。莫小君亦在视频流出后失踪。
    
      2013年,中国掀起反腐风暴。西京省委书记孙天宇退休。郑小西在西京省检察院挂职结束后继续留任,被委派为吴小南专案组成员之一。案件调查进入深水区,但吴始终不肯供认与周小东相关的情况。周小东希望救出吴小南,也为自己的仕途担忧,他认为破局的关键在于刚刚退休但仍对西京有重大影响力的孙天宇。周小东从孙天宇原秘书罗八处了解到,孙退休后痴迷德州扑克,但遍访高手不得。2014年9月,周小东经人引介,认识了一个刚从海外归来的面容已毁但牌技高超的“赌王”石贺,遂组局邀请罗八打牌,其间石贺利用千术骗取罗八5万元,罗八懊恼之余,将石贺引荐给孙天宇。石贺时输时赢,按周小东计划自然地输给孙天宇百万余元。孙已通过罗八知悉石贺的背后是周小东,对此心领神会。
    
      2014年10月,周小东拜访孙天宇,请孙在吴小南案上帮忙,孙天宇允诺。11月20日,周小东接到郑小西电话,得知吴小南知道莫小君受辱失踪后受到刺激,精神濒临崩溃,开始供出为周小东代持股份系“干股”等问题。周小东闻讯后半晌无语,明白大势已去。12月29日,周小东、王小北和郑小西突然接到失踪两年的莫小君的短信。信中表示,当年对不起郑小西,也明白王小北的心意,但与吴小南确系真心相爱。一系列事件让自己身心俱疲,本已无颜再面对吴小南和众同学,可是人生不能总是逃避。莫小君祈求三人念在同学一场,协力救出吴小南。同时向三人发出聚会邀请,相约一起跨年,以纪念毕业三十年。
    
      2014年12月31日下午,准备会后赴约的周小东,在会议上被纪委人员当场带走。当日23时许,莫小君站在西京广场观景台上,静静地等待灯光秀和昔日同窗的到来……
    
      问:案中人的刑事责任(本题100分)
    

    Install mate-desktop on Ubuntu 14.04 LTS

    sudo apt-add-repository ppa:ubuntu-mate-dev/ppa
    sudo apt-add-repository ppa:ubuntu-mate-dev/trusty-mate
    sudo apt-get update
    sudo apt-get install ubuntu-mate-core ubuntu-mate-desktop
    
    After installation, log out and select MATE session then re-login.

    reload web page every a few seconds

    • Method 1: html meta element
      <head>
      <meta http-equiv="refresh" content="10"/>
      </head>
      
    • Method 2: Use javascript(setTimeout(), window.location.reload()):
      <html>
      <body onload="setTimeout(function () { window.location.reload(1); }, 10000);">
      </body>
      </html>
      

    Python: overriding static method


    class A:
    @staticmethod
    def m():
    print "A"

    class B(A):
    @staticmethod
    def m():
    print "B"

    a = A()
    a.m() # A
    b = B()
    b.m() # B

    Python: call constructor of the super class

    • Option 1:

      class A(object):
      def __init__(self):
      print "world"

      class B(A):
      def __init__(self):
      print "hello"
      super(B, self).__init__()
    • Option 2:

      class A:
      def __init__(self):
      print "world"

      class B(A):
      def __init__(self):
      print "hello"
      A.__init__(self)

    Python: string equals ignore case


    def equals_ignore_case(s1, s2):
    if s1 is None and s2 is None:
    return True
    if s1 is None and s2 is not None:
    return False
    if s1 is not None and s2 is None:
    return False
    return s1.lower() == s2.lower()