Skip to content

Instantly share code, notes, and snippets.

@jistr
jistr / couch_fixture.rb
Created January 22, 2011 00:13
Simple YAML -> CouchDB fixture loader for Rails
# YAML -> CouchDB fixture loader for Rails
# ========================================
# by Jiri Stransky (http://twitter.com/jistr)
# for use with testing database instances only ;)
#
# What it does:
# * Loads fixtures from "test/fixtures" directory.
# * Permits use of ERB in the fixtures.
# * Uses CouchRest.
#
@jonjensen
jonjensen / MediaPlayer-excerpt.java
Created March 2, 2011 07:27
simplified example of Android sound player
/**
* Convenience method to create a MediaPlayer for a given resource id.
* On success, {@link #prepare()} will already have been called and must not be called again.
* <p>When done with the MediaPlayer, you should call {@link #release()},
* to free the resources. If not released, too many MediaPlayer instances will
* result in an exception.</p>
*
* @param context the Context to use
* @param resid the raw resource id (<var>R.raw.&lt;something></var>) for
* the resource to use as the datasource
@tistaharahap
tistaharahap / gist:1202974
Created September 8, 2011 08:57
HMAC-SHA1 Utility for Android
public static String sha1(String s, String keyString) throws
UnsupportedEncodingException, NoSuchAlgorithmException,
InvalidKeyException {
SecretKeySpec key = new SecretKeySpec((keyString).getBytes("UTF-8"), "HmacSHA1");
Mac mac = Mac.getInstance("HmacSHA1");
mac.init(key);
byte[] bytes = mac.doFinal(s.getBytes("UTF-8"));
@davidnunez
davidnunez / gist:1404789
Created November 29, 2011 13:20
list all installed packages in android adb shell
pm list packages -f
@franck
franck / monitrc
Created December 1, 2011 11:11
monit config file (nginx, mysql, redis, tomcat)
###############################################################################
## Monit control file
###############################################################################
##
## Comments begin with a '#' and extend through the end of the line. Keywords
## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
##
## Below you will find examples of some frequently used statements. For
## information about the control file, a complete list of statements and
## options please have a look in the monit manual.
@deltheil
deltheil / platform.h
Created January 12, 2012 17:53
Preprocessor: detect mobile platform (iOS vs Android)
/**
* NOTES:
* - iOS: the useful macros are defined within TargetConditionals.h
* - Android:
* - with Android.mk file(s) and the 'ndk-build' script (aka vanilla way),
* ANDROID is predefined (see -DANDROID extra C flag),
* - with the Android Standalone Toolchain __ANDROID__ is predefined instead
*/
#if defined(__APPLE__)
#include <TargetConditionals.h>
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
Subject: Thanks for signing up!
Date: {{date}}
To: {{recipient}}
From: {{sender}}
MIME-Version: 1.0
Content-Type: text/plain
Thanks for signing up for the Foobar service!
Your email address is: {{recipient}}
@albertodebortoli
albertodebortoli / gist:2204433
Created March 26, 2012 10:55
Copy file from bundle to documents directory in iOS
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.filename = @"file.ext";
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDir = [documentPaths objectAtIndex:0];
self.filePath = [documentDir stringByAppendingPathComponent:self.filename];
[self createAndCheckDatabase];
@lotem
lotem / cangjie5.custom.yaml
Last active December 18, 2021 03:14
Rime設定:以回車清除編碼串,分號、單引號鍵選擇2、3候選(以【倉頡五代】为例)
# cangjie5.custom.yaml
# save it to:
# ~/.config/ibus/rime (linux)
# ~/Library/Rime (macos)
# %APPDATA%\Rime (windows)
patch:
"key_binder/bindings":
- { when: composing, accept: Return, send: Escape }
- { when: has_menu, accept: semicolon, send: 2 }