Skip to content

Instantly share code, notes, and snippets.

@keang
keang / pre-commit
Last active November 1, 2019 12:06
pre-commit hook calling Rubocop to check staged ruby style
#!/bin/sh
# Commit this file to your project somewhere, then instruct teammates who wants to opt in to symlink to run the hook:
# ln -sf ../../pre-commit .git/hooks/pre-commit
# To capture user input
exec < /dev/tty
./style_check # or wherever you keep the style_check script
@keang
keang / gimmie-widget-text-properties.js
Last active November 6, 2015 09:53
Lists all the text available for customization for Gimmie Web Widget
"empty_reward" : "There are no rewards in the catalog right now. Please check back again while we add more rewards.",
"loading_reward" : "Loading Rewards",
"error" : "Something wrong, please close and open again later.",
"login_title_text" : "Login/Sign up",
"login_subline" : "to redeem rewards",
"login_headline" : "<p>Please login or signup to</p><p>earn points and redeem rewards</p>",
"login_button" : "Login/Signup <img data-src='{{root}}navigation-arrow.png'>",
"help_link" : "How do I earn points?",
"reward_tab_title" : "Reward",
"reward_tab_profile" : "Profile",
<?php
//error_reporting(0);
$key = '<CONSUMER KEY>'; //Get this from Gimmie portal after creating Game
$secret = '<SECRET KEY>'; //Get this from Gimmie portal after creating Game
$user_id = $_GET["u"]; //This is a demo but do use a more secure way to get the user ID (cookie/session instead)
$player_uid = $user_id;
require 'oauth'
site = 'https://api.gimmieworld.com'
consumer = OAuth::Consumer.new('key', 'secret', :site => site)
token = OAuth::AccessToken.new(consumer, 'userid', 'secret')
response = token.get('/1/profile.json')
<div id="gimmie-root"></div>
<script type="text/javascript">
var _gimmie = {
"endpoint" : "/gimmie-connect?gimmieapi=", //for Rack example above, change this field to "/gimmieapi="
"gimmie_endpoint" : "https://api-rtqa.gimmieworld.com", // An optional endpoint for bypassing secret authentication, for open API like /categories.json
"key" : "###################", //get consumer_key from the portal
"country" : "SG", //country code which affects visible rewards
"locale" : "us", //locale
//remove the user field below if no user has signed in
var Client = require('gimmie-node').Client;
var client = new Client({
oauth_key: 'key',
oauth_secret: 'secret',
url_prefix: 'https://api.gimmieworld.com'
})
client.get('/1/trigger.json?event_name=event', 'test',
function (error, response) {
if (error) return;
//Only tested in Firefox with firebug
// -> Install the firebug addon
// -> Open firebug console / press F12
// -> Copy and paste this code
// -> Click run
//To change strategy, uncomment one and comment out the other:
@keang
keang / illustrator_android_res_export.jsx
Last active August 29, 2015 13:55
An adobe illustrator script to export layers into android resources
/**
* Adobe Illustrator Script that exports each layer into PNG files according to its layer name,
* as well as making copies for various screen sizes.
*
* (1)The illustrator document should has dimensions in xxhdpi.
* One xxhdpi screen is nexus5 (480dpi) with dimensions 1920x1080px
* Launcher icon at baseline 48x48dp is 48x48px for mdpi
* so the lanucher_icon layer should be at 144x144px inside the illustrator document to be exported.
*
* (2)Modify the destination android project in line33