Skip to content

Instantly share code, notes, and snippets.

View xen0n's full-sized avatar

WÁNG Xuěruì xen0n

View GitHub Profile
@ipconfiger
ipconfiger / __init__.py
Created January 5, 2012 12:48
OAuth包,实现了sina,QQ,网易,搜狐的OAuth认证
# -*- Encoding: utf-8 -*-
import base64
import binascii
import cgi
import hashlib
import hmac
import logging
import time
import urllib
import urlparse
@upsuper
upsuper / gist:5351509
Created April 10, 2013 03:22
Simplify IP segments by removing redundant segments and merging adjacent segments.
# coding: UTF-8
import socket
import struct
def aton(addr):
return struct.unpack('!l', socket.inet_aton(addr))
def ntoa(addr):
return socket.inet_ntoa(struct.pack('!l', addr))
@keyboardr
keyboardr / FragmentUtils.java
Last active March 8, 2019 05:30
Utility method for getting the appropriate parent of a Fragment for a given callback interface.
import android.support.v4.app.Fragment;
public class FragmentUtils {
/**
* @param fragment
* The Fragment whose parent is to be found
* @param parentClass
* The interface that the parent should implement
* @return The parent of fragment that implements parentClass,
@slightfoot
slightfoot / NightModeHelper.java
Last active July 19, 2024 04:09
Night Mode Helper - Helps use utilise the night and notnight resource qualifiers without being in car or dock mode.
import java.lang.ref.WeakReference;
import android.app.Activity;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.preference.PreferenceManager;
/**
* Night Mode Helper
@yszou
yszou / alipay_mobile.py
Created June 20, 2014 04:51
支付宝移动网页支付的实现
# -*- coding: utf-8 -*-
from hashlib import md5
from urllib import urlencode
#网关
GATEWAY = 'http://wappaygw.alipay.com/service/rest.htm'
class Alipay(object):
'支付宝移动服务网关'
@JakeWharton
JakeWharton / README.md
Last active January 8, 2020 02:13
A special activity which facilitates restarting your application process.
@wong2
wong2 / cmds.txt
Last active May 2, 2021 12:13
在任意聊天中输入。 [ ]表示后面要跟一个空格(可能还需要别的参数才能生效)
//wearversion
//wearlog
//wearvoiceinputenable
//wearvoiceinputdisable
//weargoogleapi
//assert
//pushassert
//uplog
//upcrash
//switchnotificationstatus
@karpathy
karpathy / min-char-rnn.py
Last active July 24, 2024 18:36
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@Francesco149
Francesco149 / shige-skins.md
Last active March 31, 2024 14:53
Shigetora / Cookiezi skin compilation
@whitlockjc
whitlockjc / example.el
Created March 9, 2016 18:25
Emacs linum-format that works around whitespace-mode and padding
;; Linum mode
(global-linum-mode t)
;; Custom face/function to pad the line number in a way that does not conflict with whitespace-mode
(defface linum-padding
`((t :inherit 'linum
:foreground ,(face-attribute 'linum :background nil t)))
"Face for displaying leading zeroes for line numbers in display margin."
:group 'linum)