Skip to content

Instantly share code, notes, and snippets.

View jarontai's full-sized avatar
📖
I may be slow to respond.

Jaron Dai jarontai

📖
I may be slow to respond.
View GitHub Profile
// For Get
// set HTTP header
$headers = array(
'Content-Type: application/json',
);
// query string
$fields = array(
'key' => '<your_api_key>',
@jarontai
jarontai / gist:11395184
Created April 29, 2014 09:28
postgre sql osx connect problem
Here is the fix, more info here:
https://github.com/mxcl/homebrew/issues/5004
First, stop the db, then
cd /var
rm -r pgsql_socket
ln -s /tmp pgsql_socket
chown _postgres:_postgres pgsql_socket
@jarontai
jarontai / php curl post
Created April 16, 2014 02:06
php curl post
function post_to_url($url, $data) {
$fields = '';
foreach($data as $key => $value) {
$fields .= $key . '=' . $value . '&';
}
rtrim($fields, '&');
$post = curl_init();
curl_setopt($post, CURLOPT_URL, $url);
@jarontai
jarontai / gist:9106463
Created February 20, 2014 03:13
Close window
if (navigator.userAgent.indexOf("MSIE") > 0) {
if (navigator.userAgent.indexOf("MSIE 6.0") > 0) {
window.opener = null; window.close();
}
else {
window.open('', '_top'); window.top.close();
}
}
else if (navigator.userAgent.indexOf("Firefox") > 0) {
window.location.href = 'about:blank ';
@jarontai
jarontai / Font SegoeUI Light
Created January 20, 2014 06:41
Font SegoeUI Light
font-family: "wf_SegoeUILight","wf_SegoeUI","Segoe UI Light","Segoe WP Light","Segoe UI","Segoe","Segoe WP","Tahoma","Verdana","Arial","sans-serif";
@jarontai
jarontai / make angular display invalid input value
Created November 13, 2013 02:35
make angular display invalid input value
app.directive('input', function() {
return {
require: '?ngModel',
restrict: 'E',
link: function($scope, $element, $attrs, ngModelController) {
var inputType = angular.lowercase($attrs.type);
if (!ngModelController || inputType === 'radio' ||
inputType === 'checkbox') {
return;
@jarontai
jarontai / android delete folder
Created September 24, 2013 06:17
android delete folder
void DeleteRecursive(File fileOrDirectory) {
if (fileOrDirectory.isDirectory())
for (File child : fileOrDirectory.listFiles())
DeleteRecursive(child);
fileOrDirectory.delete();
}
@jarontai
jarontai / android unzip file
Created September 24, 2013 06:15
android unzip file
private boolean unpackZip(String path, String zipname)
{
InputStream is;
ZipInputStream zis;
try
{
String filename;
is = new FileInputStream(path + zipname);
zis = new ZipInputStream(new BufferedInputStream(is));
ZipEntry ze;
@jarontai
jarontai / Skip over auto-completed tags in Sublime Text 2
Last active December 23, 2015 10:49
Skip over auto-completed tags in Sublime Text 2
{ "keys": ["tab"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "selection_empty", "operator": "equal", "operand": true },
{ "key": "preceding_text", "operator": "not_regex_match", "operand": "[[:space:]]*", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^[\"'\\)\\}\\]\\_]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false },
{ "key": "has_next_field", "operator": "equal", "operand": false }
]
}