Skip to content

Instantly share code, notes, and snippets.

@dht
dht / anonymous.java
Last active Mar 30, 2016
Anonymous users in parse.com Android
View anonymous.java
ParseUser.enableAutomaticUser();
ParseUser.getCurrentUser().saveInBackground();
@dht
dht / AbsolutePosition
Last active Sep 24, 2015
JS assistance to design CSS - helps you drag and drop your absolute HTML elements visually and then retrieve their left/top/right/bottom CSS
View AbsolutePosition
var data = {};
$('body').mousedown(function (event) {
data.element = event.toElement;
data.top = parseInt($(data.element).css('top'), 10);
data.bottom = parseInt($(data.element).css('bottom'), 10);
data.right = parseInt($(data.element).css('right'), 10);
data.left = parseInt($(data.element).css('left'), 10);
data.vField = isNaN(data.top) ? 'bottom' : 'top';
data.vValue = $(data.element).css(data.vField);
@dht
dht / Useful linux commands
Last active Dec 31, 2015
Those are useful linux commands to manage our Ubuntu server
View Useful linux commands
# Enable proxy
sudo a2enmod proxy_http
# Start mongodb daemon
mongod --fork --logpath /data/db/mongod.log
# Stop mongodb daemon
mongod --shutdown
# Start nodejs daemon
@dht
dht / gist:6096598
Created Jul 27, 2013
Start fresh with Git and make a repository's last commit the only commit
View gist:6096598
$ git checkout --orphan new-master master
$ git commit -m "Initial commit for new root"
$ git branch -D master
$ git branch --move new-master master
@dht
dht / interface.ts
Created Jul 26, 2013
interfaces in typescript
View interface.ts
interface Shape {
name: string;
width: number;
height: number;
color?: string;
}
function area(shape : Shape) {
var area = shape.width * shape.height;
return "I'm " + shape.name + " with area " + area + " cm squared";
@dht
dht / svgGrid
Created Jul 26, 2013
how to create a grid with SVG
View svgGrid
<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
<defs>
<pattern id="smallGrid" width="8" height="8" patternUnits="userSpaceOnUse">
<path d="M 8 0 L 0 0 0 8" fill="none" stroke="#333" stroke-opacity="0.5" stroke-width="0.5"/>
</pattern>
<pattern id="grid" width="80" height="80" patternUnits="userSpaceOnUse">
<rect width="80" height="80" stroke="gray" stroke-width="1" stroke-opacity="0.5" fill="url(#smallGrid)"/>
<path d="M 80 0 L 0 0 0 80" fill="none" stroke="gray" stroke-width="2"/>
</pattern>
</defs>
@dht
dht / gist:3170509
Created Jul 24, 2012
log in objectiveC
View gist:3170509
NSLog(@"log: %@ ", myString);
NSLog(@"log: %f ", myFloat);
NSLog(@"log: %i ", myInt);
You can’t perform that action at this time.