Skip to content

Instantly share code, notes, and snippets.

View xinthink's full-sized avatar

Yingxin Wu xinthink

View GitHub Profile
@joshbirk
joshbirk / samplerest.js
Created February 3, 2012 19:57
Sample of using passport w/ mult strategies
var fs = require("fs")
var ssl_options = {
key: fs.readFileSync('privatekey.pem'),
cert: fs.readFileSync('certificate.pem')
};
var port = process.env.PORT || 3000;
var express = require('express');
var ejs = require('ejs');
var passport = require('passport')
@hzlzh
hzlzh / GitHub-Shop-Group-Purchase.md
Created February 22, 2012 06:25
GitHub Shop Group Purchase

#GitHub Shop Group Purchase ###By:@[hzlzh] 活动地址:http://shop.github.com/
V2EX:[http://www.v2ex.com/t/27492][V2EX]

##活动经验提炼:(写给今后可能的,别的组织者)

  • 仅此一次,本人不会再组织GitHub团了,如果只买贴纸可以考虑。因为瓷器和玻璃制品易碎,在快递行业中和iPad属于一个级别的易损坏品。申通和圆通这类的会拒发,而且不能保价。 (来源于SF快递员)
  • 如果有人要买GitHub Shop中的东西,依然建议另寻组团购买,原因如下:
  1. 组团官方使用大箱子发送到中国,这期间会很安全,你想想,会有那个快递员疯了去扔大箱子?(快递的分发是空抛这种扔来扔去的这个是快递行业内部无法避免的),一个小盒子过来中国,八成会碎,先走UPSP然后是国内邮政平邮
  2. 美国->中国 邮费 $20或$30两个档次,差不多¥100多邮费,比有些东西还贵,如果几个朋友一起,何乐而不为?
@n1ywb
n1ywb / retries.py
Created May 1, 2012 17:48
A Python function retrying decorator
#!/usr/bin/env python
#
# Copyright 2012 by Jeff Laughlin Consulting LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@guerrerocarlos
guerrerocarlos / main.js
Created September 6, 2012 05:07
loading socket.io using require.js
// Require.js allows us to configure shortcut alias
require.config({
// The shim config allows us to configure dependencies for
// scripts that do not call define() to register a module
shim: {
'socketio': {
exports: 'io'
},
'underscore': {
exports: '_'
@arriolac
arriolac / TopCropImageView.java
Last active June 10, 2024 10:15
Custom Android ImageView for top-crop scaling of the contained drawable.
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.ImageView;
/**
* Created by chris on 7/27/16.
@wbroek
wbroek / genymotionwithplay.txt
Last active February 12, 2024 03:22
Genymotion with Google Play Services for ARM
NOTE: Easier way is the X86 way, described on https://www.genymotion.com/help/desktop/faq/#google-play-services
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 6.0 (https://www.androidfilehost.com/?fid=24052804347835438 - benzo-gapps-M-20151011-signed-chroma-r3.zip)
Google Apps for Android 5.1 (https://www.androidfilehost.com/?fid=96042739161891406 - gapps-L-4-21-15.zip)
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)
@skyfishjy
skyfishjy / CursorRecyclerViewAdapter.java
Last active December 16, 2023 08:55
CursorRecyclerViewAdapter
/*
* Copyright (C) 2014 skyfish.jy@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@PuKoren
PuKoren / codeship_android_build.sh
Last active February 1, 2024 19:35 — forked from mlocher/install_android_sdk.sh
Codeship Android build script
cd /tmp
pwd
#Download Android SDK from Google and unzip it
wget http://dl.google.com/android/android-sdk_r24.1.2-linux.tgz
tar zxvf android-sdk_r24.1.2-linux.tgz
rm android-sdk_r24.1.2-linux.tgz
#Set extracted SDK location to $PATH so we can use commands
export ANDROID_HOME="/tmp/android-sdk-linux"
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH"
@xinthink
xinthink / slack-on-repo-starred.js
Last active August 29, 2015 14:26
A LeanEngine function that sends a Slack notification when the given GitHub repo got starred.
// parameters of the function
var repo = request.params.repo; // 'user_or_org/repo_name'
var slackWebhook = request.params.slackWebhook; // e.g. 'https://hooks.slack.com/services/XXX'
var repoUrl = 'https://api.github.com/repos/' + repo;
// Set the following names to match your own scheme
var className = 'RepoStars'; // LeanCloud class for storing repo stars
var fieldRepo = 'repo'; // LeanCloud field to store the repo name
var fieldStars = 'count'; // LeanCloud field to store the count of stars