Skip to content

Instantly share code, notes, and snippets.

@Usse
Usse / random.proc
Last active December 31, 2015 02:19
Processing Random colour and dimension
void setup() {
size(480,120);
}
void draw() {
int[] colours = {255, 100, 10};
if(mousePressed) {
fill(0);
@Usse
Usse / build.sh
Created November 15, 2013 09:21
Build an AIR application
adt -package -storetype pkcs12 -keystore sampleCert.p12 HelloWorld.air HelloWorld-app.xml HelloWorld.html AIRAliases.js
@Usse
Usse / app.js
Last active December 27, 2015 11:49
Parse latest reddit article and insert them in a Mongo db collection.
var MongoClient = require('mongodb').MongoClient
, request = require('request');
MongoClient.connect('mongodb://localhost:27017/reddit', function(err, db) {
if(err) throw err;
request('http://www.reddit.com/r/webdev/.json', function(error,response,body) {
if(!error && response.statusCode == 200) {
var obj = JSON.parse(body);
var stories = obj.data.children.map(function(story) {return story.data;});
db.collection('webdev').insert(stories, function(err,data) {
@Usse
Usse / fullscreen.js
Created October 29, 2013 09:04
Detect if the app is installed ( and in fullscreen mode )
if(window.navigator.standalone == true) {
// My app is installed and therefore fullscreen
}
@Usse
Usse / ff
Created October 27, 2013 23:36
Find string in the currently directory. usage: ff string
#!/bin/sh
grep -R $1 * --color --exclude-dir=node_modules --exclude-dir=.svn --exclude-dir=.git
@Usse
Usse / nh_titles.rb
Created August 30, 2013 08:52
Latest HN titles in the console!
require 'rss/1.0'
require 'rss/2.0'
require 'open-uri'
source = "https://news.ycombinator.com/rss"
content = ""
open(source) do |s|
content = s.read
end
rss = RSS::Parser.parse(content, false)
@Usse
Usse / h1.less
Created August 28, 2013 14:39
Less H1 dimensions generator
@iterations: 6;
.h(@index) when (@index > 0) {
h@{index} {
font-size: 72px - @index*10;
}
.h(@index - 1);
}
.h(0) {}
@Usse
Usse / linen.js
Created August 22, 2013 15:38
Prevent linen on iPad
$(document).bind(
'touchmove',
function(e) {
e.preventDefault();
}
);
@Usse
Usse / flickering.css
Created August 13, 2013 12:51
Prevent flickering problems in Webkit
.box {
-webkit-backface-visibility: hidden;
}
@Usse
Usse / colors.js
Created July 26, 2013 08:01
Colors RGB array
colors = {
black: [0, 0, 0],
white: [255, 255, 255],
transparent: [255, 255, 255, 0],
aqua: [0, 255, 255],
lime: [0, 255, 0],
silver: [192, 192, 192],
maroon: [128, 0, 0],
teal: [0, 128, 128],
blue: [0, 0, 255],