Skip to content

Instantly share code, notes, and snippets.

View qunwang6's full-sized avatar
🏠
Working from home

qunwang6

🏠
Working from home
View GitHub Profile
@qunwang6
qunwang6 / STRD.lua
Created October 16, 2015 02:33 — forked from Revolution1/STRD.lua
lua的openwrt拨号脚本,用于四川电信校园网
#!/usr/bin/env lua
function md5sum(str)
local command="echo -n "..str.." | md5sum"
local f=io.popen(command)
local out=f:read('*all')
return out:sub(1,-5)
--f:close()
end
--print(md5sum("asdf")) -- 912ec803b2ce49e4a541068d495ab570
@qunwang6
qunwang6 / level.lua
Last active August 29, 2015 14:26 — forked from masakichi/level.lua
战舰少女touchelf脚本
SCREEN_RESOLUTION="640x1136";
SCREEN_COLOR_BITS=32;
function isDone()
touchDown(4, 40, 876)
mSleep(200);
touchUp(4)
end
function checkLongWar()
@qunwang6
qunwang6 / dedict.c
Last active August 29, 2015 14:24 — forked from josephg/0dedict.py
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "zlib.h"
#define CHUNK 16384
/*
40 Length of the zlib stream

Mac OSX Spotlight Enhancement

Add this to Info.plist in /System/Library/Spotlight/RichText.mdimporter/Contents/ and Spotlight will search for source code files.

<string>public.c-header</string>
<string>public.c-plus-plus-header</string>
<string>public.c-source</string>
<string>public.objective-c-source</string>
public.c-plus-plus-source

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

javascript:(function(){script=document.createElement('script');script.src='http://dict.bing.com.cn/cloudwidget/Scripts/Generated/BingTranslate_Hover_Phrase_Selection_ShowIcon.js';script.onload=INIT;document.body.appendChild(script);})();function INIT(){BingCW.Init({MachineTranslation:true,WebDefinition:true});}

General Usage

Most of the following commands can be used both on files directly and in pipes, e.g. the command sed G can be used in both of the following ways:

... | sed G
sed G [/path/to/]file
@qunwang6
qunwang6 / dict.c
Last active August 29, 2015 14:07
/*
* Command-line dictionary lookup.
*
* Build with:
* clang -framework CoreServices
*/
#import <CoreFoundation/CoreFoundation.h>
#import <CoreServices/CoreServices.h>
int main(int argc, char *argv[]) {
#!/bin/sh
# == References
#
# * OSXでMP4動画からAAC音声抽出
# http://d.hatena.ne.jp/ikki_j/20080304/1204629353
# > H.264+AACなMP4動画から再コンパイルなしでAAC音声のみを抽出する方法。
#
# * EvalVid - A Video Quality Evaluation Tool-set Pre-compiled binaries (static)
# http://www2.tkn.tu-berlin.de/research/evalvid/fw.html#bin
# -*- coding: utf-8; -*-
#
# Author :: Masayuki Higashino
#
# This plugin looks up a word beside a caret or a selected text in
# Dictionary.app without changing activeness of Sublime Text 2.app's window.
#
# In order to use this plugin, Add a keymap such as a follow into user's key bindings.
# { "keys": ["super+d"], "command": "look_up_in_dictionary" }