This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ip2int = ip => ip.split('.').reverse().map((v, i) => +v << (8 * i)).reduce((s, a) => s | a); | |
const int2ip = it => it.toString(2).padStart(32, 0).match(/.{8}/g).map(v => parseInt(v, 2)).join('.'); | |
// test | |
console.log(ip2int(`127.0.0.1`)); // 2130706433 | |
console.log(int2ip(2130706433)); // 127.0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
#Step 1 - Generate server certificates etc... (most of this code is horribly ripped off from nodejs docs currently -> http://nodejs.org/docs/latest/api/tls.html) | |
### | |
#Assuming your starting from a clean directory | |
mkdir server | |
cd server | |
#generate private key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Simple excel writer class with no external dependencies, drop it in and have fun | |
* @author Matt Nowack | |
* @link https://gist.github.com/ihumanable/929039/edit | |
* @license Unlicensed | |
* @version 1.0 | |
*/ | |
class Excel { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.swift | |
// test-swift3 | |
// | |
// Created by jesse on 2016/11/5. | |
// Copyright © 2016年 jesse. All rights reserved. | |
// | |
// #!/usr/bin/env swift | |
import Foundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
class KFetch { | |
let session: NSURLSession = NSURLSession.sharedSession() | |
// url安全编码 | |
func escape(str: String) -> String { | |
let characterSet = NSMutableCharacterSet.alphanumericCharacterSet() | |
characterSet.addCharactersInString("-._ ") | |
if #available(iOS 8.3, *) { | |
return str.stringByAddingPercentEncodingWithAllowedCharacters(characterSet)!.stringByReplacingOccurrencesOfString(" ", withString: "+") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dir='/home/kirigayaloveyousei/Wallpaper/' | |
while :; do | |
for d in $(ls -F $dir|grep /); do | |
for f in $(ls $dir$d); do | |
gsettings set org.gnome.desktop.background picture-uri file://$dir$d$f | |
echo "正在设置壁纸,壁纸来自:" $dir$d$f | |
sleep 60 | |
done | |
done | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func escape(str: String) -> String { | |
let characterSet = NSMutableCharacterSet.alphanumericCharacterSet() | |
characterSet.addCharactersInString("-._ ") | |
if #available(iOS 8.3, *) { | |
return str.stringByAddingPercentEncodingWithAllowedCharacters(characterSet)!.stringByReplacingOccurrencesOfString(" ", withString: "+") | |
} | |
let length = str.characters.count | |
let num = 50 | |
let times = length > (length / num * num) ? length / num + 1 : length / num | |
var result = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dataURItoBlob(dataURI) { | |
var byteString = atob(dataURI.split(',')[1]); | |
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; | |
var ab = new ArrayBuffer(byteString.length); | |
var dw = new DataView(ab); | |
for (var i = 0; i < byteString.length; i++) { | |
dw.setUint8(i, byteString.charCodeAt(i)); | |
} | |
return new Blob([ab], {type: mimeString}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var FS = require('fs'); | |
var pending = callback => { | |
var count = 0; | |
var returns = {}; | |
console.log("Start cound: %d", count); | |
return key => { // a function done | |
count++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |