Skip to content

Instantly share code, notes, and snippets.

View frontweb's full-sized avatar

Radu Cojocaru frontweb

View GitHub Profile
@frontweb
frontweb / utils.js
Created April 30, 2019 12:41
Javascript Utils
// Create a new object with a subset of fields - it's useful in react-redux' connect()
// pick('name')({name: 'John', age: 35}) => {name: 'John'}
export const pick = (...fields) => o => fields.reduce((result, field) => {
result[field] = o[field];
return result;
}, {})
@frontweb
frontweb / gist:1487080
Created December 16, 2011 17:43
Catch any touch event in an Android app
@Override
public boolean dispatchTouchEvent(MotionEvent event){
resetSessionTimeout();
super.dispatchTouchEvent(event);
return false;
}
for (ListIterator iter = annotsArray.listIterator(); iter.hasNext();)
{
PdfDictionary annot = (PdfDictionary) PdfReader.getPdfObject( iter.next());
PdfString content = (PdfString) PdfReader.getPdfObject(annot.get(PdfName.WIDTH));
if (content != null) {
System.out.println(content);
}
}
@frontweb
frontweb / uitextfield_validation.m
Created May 4, 2011 09:47
Get UITextField text as you type
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
NSMutableString* newText = [[NSMutableString alloc] init];
[newText appendString:[textField.text substringWithRange:NSMakeRange(0, range.location)]];
[newText appendString:string];
NSLog(@"newText: %@", newText);
}
@frontweb
frontweb / uk_post_code.html
Created March 19, 2011 19:44
Plot a UK post code on Google Maps
<html>
<head>
<title>UK Post Code</title>
<style type="text/css">
#map_canvas { width:300px; height:200px; }
</style>
<script type="text/javascript">
function initialize() {
@frontweb
frontweb / Terminal Tabs in AppleScript.scpt
Created October 24, 2010 10:34
How To Open Terminal Tabs From An AppleScript
tell application "Terminal"
activate
do script "cd my-project; ./script/server"
tell application "System Events" to tell process "Terminal.app" to keystroke "t" using command down
do script "cd my-project; mate ." in front window
tell application "System Events" to tell process "Terminal.app" to keystroke "t" using command down
do script "cd my-project; ./script/console" in front window
end tell
var sys = require('sys'),
http = require('http'),
url = require('url'),
request = require('./vendor/plugins/request/main');
// Connect to DB
var db = require('./vendor/plugins/nodejs-mysql-native/mysql/client').createTCPClient('localhost', 8889);
db.auth('db_name', 'root', 'root');
// Server