Skip to content

Instantly share code, notes, and snippets.

@dannvix
dannvix / c99-heap.c
Created October 8, 2015 14:58
Simple std::priority_queue-like container implemented in C99, without error handling and thread-safety
/*
* c99-heap.c
* - Description: Simple std::priority_queue-like container implemented in C99, without error handling and thread-safety
* - Author: Shao-Chung Chen
* - License: CC0
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
@dannvix
dannvix / c99-vector.c
Created October 8, 2015 14:57
Simple std::vector-like container implemented in C99, without error handling and thread-safety
/*
* c99-vector.c
* - Description: Simple std::vector-like container implemented in C99, without error handling and thread-safety
* - Author: Shao-Chung Chen
* - License: CC0
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@FlandreDaisuki
FlandreDaisuki / FB.rainbow.CSSgradient.js
Last active August 29, 2015 14:23
paste on console and 🌈
function repImg( tar ) {
var div = document.createElement( 'div' );
div.style.height = tar.height + 'px';
div.style.width = tar.width + 'px';
div.style.display = 'inline-block';
div.style.backgroundColor = 'transparent';
// http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
var isFirefox = typeof InstallTrigger !== 'undefined';
anonymous
anonymous / gist:de6b81c556b5dc7cdc8b
Created February 20, 2015 01:42
Kernel panic in latest OS X in 10 lines of C
#include <unistd.h>
#include <mach/mach.h>
#include <mach/mach_vm.h>
#include <mach-o/dyld.h>
int
main (int argc, char * argv[])
{
volatile char * library;
const mach_vm_size_t page_size = getpagesize ();
@dannvix
dannvix / PocketWebCustomization.user.js
Last active February 12, 2018 05:46
Customization/Simplification for Pocket Web
// ==UserScript==
// @name Pocket Web Customized
// @description Cusotmizations/Simplifications for Pocket Web
// @namespace http://getpocket.com
// @author Shao-Chung Chen
// @license MIT (http://opensource.org/licenses/MIT)
// @version 1.9.1
// @include http://getpocket.com/*
// @include https://getpocket.com/*
//
@dannvix
dannvix / shooter-subdl.py
Last active February 26, 2016 12:19
command-line downloader for shooter.cn subtitles
#!/usr/bin/env python
import os
import re
import md5
import sys
import json
import urllib
import urllib2
try:
require 'digest'
filename = "House.Of.Cards.2013.S02E01.720p.WEB-DL.x264-Sohu.mp4"
f = File.new(filename, "rb")
puts f.stat.inspect
file_size = File.size?(filename)
offset = []
@ihower
ihower / gist:6132576
Last active June 12, 2019 05:42
Git commit without commit
# First commit
echo "hello" | git hash-object -w --stdin
git update-index --add --cacheinfo 100644 ce013625030ba8dba906f756967f9e9ca394464a hello.txt
git write-tree
git commit-tree aaa96c -m "First commit"
git update-ref refs/heads/master 30b060d9a7b5e93c158642b2b6f64b2b758da40d
# Second commit
{
"binary_file_patterns":
[
"*.psd"
],
"close_windows_when_empty": false,
"color_scheme": "Packages/Tomorrow Color Schemes/Tomorrow-Night.tmTheme",
"detect_indentation": false,
"disable_formatted_linebreak": true,
"drag_text": false,
@CrBoy
CrBoy / jquery.keycode_event.js
Created May 12, 2013 08:30
可以讓 jQuery 綁定鍵盤事件時指定只對特定按鍵作用的小程式。 使用方式: 1. 引入 jQuery 後,引入此 js 檔 2. 在綁定事件時這樣寫: $(this).keypress(13)(handler); 其中 $(this) 可代換成任何 jQuery 物件,handler 則是一般用於事件的 callback function。在此範例中,僅有當按下的按鍵為 enter 時, handler 才會作用。
var extend_keyboard_event_with_keycode = function(original_event_name) {
var $fn_original = $.fn[original_event_name];
var keyboard_event_function_wrapper = function(keycodes, handler) {
return function(e) {
if(keycodes.indexOf(e.which) != -1)
return handler(e);
}
}