This file contains hidden or 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 |
This file contains hidden or 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
// Compile list of tokens based on deletions, and respecting max edit distance | |
// Original implementation would concatenate left/right string segments using memcpy() etc, but that didn't seem right | |
// The idea is, to instead partition S into 1+ segments and build hash from them, no need for memory copies etc. | |
// This is almost x8 times faster compared to that - but it's still in the 10s of microseconds range. | |
// | |
// ( for a 31 characters long string, with max edit distance = 2, it takes 24 microseconds, including the cost for computing the FNV rolling hash ) | |
#include <switch.h> | |
#include <switch_print.h> | |
#include <ansifmt.h> |
This file contains hidden or 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 | |
define('APP_PATH', dirname(__FILE__)); | |
define('DATA_FILE', APP_PATH. '/sms.htdata'); | |
if ($_SERVER['REQUEST_METHOD'] == 'POST') { //tasker提交 | |
if (!isset($_POST['c'])) { | |
die('Invalid Request!'); | |
} else { | |
$data = ''; | |
if (file_exists(DATA_FILE)) { //读入已有数据 |
This file contains hidden or 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 createGIF(with images: [UIImage], loopCount: Int = 0, frameDelay: Double, callback: (data: NSData?, error: NSError?) -> ()) { | |
let fileProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFLoopCount as String: loopCount]] | |
let frameProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFDelayTime as String: frameDelay]] | |
let documentsDirectory = NSTemporaryDirectory() | |
let url = NSURL(fileURLWithPath: documentsDirectory)?.URLByAppendingPathComponent("animated.gif") | |
if let url = url { | |
let destination = CGImageDestinationCreateWithURL(url, kUTTypeGIF, UInt(images.count), nil) | |
CGImageDestinationSetProperties(destination, fileProperties) |