Skip to content

Instantly share code, notes, and snippets.

@6david9
6david9 / gist:8293983
Created January 7, 2014 02:53
Hex to decimal
#! /bin/sh
# 获取第一个参数
hex=$1
# 如果参数长度不等于 6,退出
if [ ${#hex} -lt 6 ]
then
echo "参数长度错误,$hex:${#hex}"
exit -1
@6david9
6david9 / gist:8294024
Created January 7, 2014 02:59
upload image using curl
#! /bin/bash
files='ls *.JPG'
for file in $files
do
filename="file=@$file"
curl -F "action=uploading" -F $filename http://path/to/uploadimg.do
@6david9
6david9 / wwdc2014_sessions
Last active January 21, 2016 09:53
wwdc2014 sessions download links
import os.path
import requests
from lxml import etree
file_path = 'https://developer.apple.com/videos/wwdc/2014/'
sd_path = os.path.expanduser("~/Desktop/wwdc2014_sd.txt")
hd_path = os.path.expanduser("~/Desktop/wwdc2014_hd.txt")
pdf_path = os.path.expanduser("~/Desktop/wwdc2014_pdf.txt")
@6david9
6david9 / htob
Created October 23, 2014 06:25
hex to binary
str = ARGF.argv[0].strip.downcase
if str.start_with? '0x'
str.delete! '0x'
end
str.each_char do |c|
bin = c.to_i(16).to_s(2)
bin.insert(0, '0' * (4-bin.length)) if bin.length < 4
@6david9
6david9 / week
Created March 9, 2015 16:48
计算万年历星期(基姆拉尔森)
#include <stdio.h>
/*
* 基姆拉尔森计算公式
* W= (d+2*m+3*(m+1)/5+y+y/4-y/100+y/400) mod 7
*/
int week(int y, int m, int d)
{
if (m < 3) {
m += 12;
@6david9
6david9 / parse_ipa.py
Created March 25, 2015 07:12
parse ipa
# -*- coding: UTF-8 -*-
import zipfile
import biplist
import tempfile
import shutil
import re
import os
@6david9
6david9 / fill_image
Created August 10, 2016 09:46
aspect fill image
- (void)drawRect:(CGRect)rect
{
if (!self.image) {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, self.backgroundColor.CGColor);
CGContextFillRect(context, rect);
return;
}
CGFloat w = CGRectGetWidth(self.frame);
set -g prefix C-g
setw -g mode-keys vi
unbind C-b
bind C-g send-prefix
bind -n C-\ split-window -h
bind -n C-M-\ split-window
bind -n F1 list-keys
#!/usr/bin/env ruby
require "date"
class Date
def weekday
case self.wday
when 0 then "日"
when 1 then "一"
when 2 then "二"
@6david9
6david9 / shortcuts.ahk
Last active December 20, 2021 15:51
simulate emacs nativate operations using auto hot key
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetCapsLockState, AlwaysOff
+!m::SendInput +^m
!s::SendInput ^s
!a::SendInput ^a