Skip to content

Instantly share code, notes, and snippets.

View frhd's full-sized avatar
🏠
Working from home

farhad frhd

🏠
Working from home
  • quantyc
  • Göttingen, Germany
  • 04:05 (UTC +02:00)
  • X @frhd27
View GitHub Profile
@frhd
frhd / css div fadeout
Created February 3, 2014 14:47
css div fadeout
#fadeout {
z-index: 50;
position: fixed;
left: 0;
top: 0;
right: 0;
height: 100px;
background: -webkit-gradient(linear, left top, left bottom, from(rgba(255, 255, 255, 255)), to(rgba(255, 255, 255, 0)));
background: -moz-linear-gradient(top, rgba(255, 255, 255, 255), rgba(255, 255, 255, 0));
@frhd
frhd / css less #1
Created February 7, 2014 12:36
css less negative numbers and absolute centering
@divwith: 1600px;
.superdiv {
overflow: auto;
height: 100%;
position: absolute;
width: @divwith;
margin-left: -(@divwith/2);
left: 50%;
}
@frhd
frhd / CoffeeScript One Liners
Last active August 29, 2015 13:56
CoffeeScript One Liners
# @ricardo.cc
# Multiply each item in a list by 2
[1..10].map (i) -> i*2
# or
i * 2 for i in [1..10]
# Sum a list of numbers
[1..1000].reduce (t, s) -> t + s
@frhd
frhd / Parsing JSON in Java
Created February 18, 2014 14:10
Parsing JSON in Java
JSONObject obj = new JSONObject("{interests : [{interestKey:Dogs}, {interestKey:Cats}]}");
List<String> list = new ArrayList<String>();
JSONArray array = obj.getJSONArray("interests");
for(int i = 0 ; i < array.length() ; i++){
list.add(array.getJSONObject(i).getString("interestKey"));
@frhd
frhd / infinite loop
Created February 20, 2014 10:29
infinite loop threading etc
public class Main {
public static volatile int x = 0;
public static void main(String[] args) {
LoopingThread t = new LoopingThread();
t.start();
while (true) {
x = x++;
}
}
}
@frhd
frhd / git pull all
Created February 20, 2014 12:08
git pull to all git directories
find . -mindepth 1 -maxdepth 1 -type d -exec git --git-dir={}/.git --work-tree=$PWD/{} pull origin master \;
@frhd
frhd / jstree 1 new node
Created February 21, 2014 15:48
jstree v1.0.0: create a new node
$("#tree-container").jstree("create", $("#new_node"), "inside", {"data":"new_node"}, false, true);
@frhd
frhd / pixel.html
Last active August 29, 2015 13:56
drawing pixels in css3
<div class="sprite">
</div>
#! /usr/bin/env python2
# Requires: PIL, colormath
#
# Improved algorithm now automatically crops the image and uses much
# better color matching
from PIL import Image, ImageChops
from colormath.color_objects import RGBColor
import argparse
import math
@frhd
frhd / timer.cpp
Created March 5, 2014 11:25
measuring seconds with c++
#include <ctime>
void f() {
using namespace std;
clock_t begin = clock();
code_to_time();
clock_t end = clock();
double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;