Skip to content

Instantly share code, notes, and snippets.

View rankun203's full-sized avatar
🔨
building things

Kun R rankun203

🔨
building things
View GitHub Profile
html {
z-index: 0;
filter: grayscale(100%);
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter ….3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale");
filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
-webkit-filter: grayscale(1);
@rankun203
rankun203 / FileDownloadThumbnailAction.java
Last active August 29, 2015 14:01
Get Cropped image using Scalr.
//get file from Mongo Grid file system.
GridFSDBFile file = fileService.getFile(fileId);
//将图片文件转换成一个BufferedImage对象
BufferedImage image = ImageIO.read(file.getInputStream());
//执行对应的操作
BufferedImage thumbnail = Scalr.resize(image, 150);
//获取文件的格式
#!/bin/bash
#checkHosts.sh
#author rankun203@gmail.com
function success {
echo "isok $1 $2"
echo "$1 $2" >> ./hosts.ok
}
@rankun203
rankun203 / GetGeo.java
Last active August 29, 2015 14:02
The distance between "Chengdu Vocational Technical College" and "Royal Garden"
/**
* Created on 14-6-15
*
* output:
* 2.787433034459691 Miles
* 4.485938629409498 Kilometers
* 2.4206068471247955 Nautical Miles
*
* Original post by dommer on StackOverflow: http://stackoverflow.com/a/3694410/1904043
*
import java.util.Arrays;
/**
* Created on 14-6-18
* output:
50058:49942
So, get0or1 works fine.
[12674, 12405, 12604, 12519, 12321, 12520, 12528, 12429]
* @author rankun203@gmail.com
*/
@rankun203
rankun203 / mwww.sh
Last active August 29, 2015 14:02
监视文件夹并执行操作
#!/bin/bash
#author rankun203@gmail.com
#ref http://unix.stackexchange.com/a/24955
cd /home/rankun203
inotifywait -r -m ./www -e create -e moved_to |
while read path action file; do
echo "The file '$file' appeared in directory '$path' via '$action'"
rsync -avzrhu --update --progress --chmod=u+rwx,g+rwx,o+rwx "$path$file" rankun203@s.rankun.org:/home/rankun203/html/files
done
@rankun203
rankun203 / charascii.c
Last active August 29, 2015 14:06
Print ASCII code of a Character (or an ASCII code table)
#include <stdio.h>
#include <conio.h>
/**
* author: rankun203@gmail.com
* Usage:
* -With Parameter
* CMD: charascii.exe A
* OutPut: A: 65
* -Without Parameter
@rankun203
rankun203 / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@rankun203
rankun203 / OSXNotes.md
Last active August 29, 2015 14:08
Notes of OSX daily use.

###Finder

Keys:

Desc Key
Move here Option+CMD+V

Commands:

@rankun203
rankun203 / resizeParent.js
Created October 27, 2014 07:57
iFrame resize parent height.
if(parent.frames.length == 0) {
// AW: always be inside a Colnect page
var dst = location.href.replace(/\/forums/, '/forum').replace(/\.php[\?]?/, '!');
top.location.replace(dst);
} else {
try {
url = parent.location.href;
pos = url.search(/\/\w\w(\W|$)/);
lang = url.substring(pos+1,pos+3);
dst = location.href.replace(/\/forums/, '/'+lang+'/forum').replace(/\.php[\?]?/, '!').replace(/lang=\w\w&?/, '');