Skip to content

Instantly share code, notes, and snippets.

View cimi's full-sized avatar
☀️

Alex Ciminian cimi

☀️
View GitHub Profile
@cimi
cimi / local_city_names.py
Created March 9, 2011 17:24
Enriches geonames.org information with local city names drawn from Google
import urllib
import urllib2
import json
import pprint
import codecs
import sqlite3
import sys
import logging
import time
@cimi
cimi / Expandable.js
Created January 13, 2012 12:43
Generic Functions for OOP in JavaScript
define([], function () {
var helpers;
var Expandable = new Class;
Expandable.include({
init : function (element) {
this.el = element;
this.parentList = helpers.getParentList(this.el);
this.menu = helpers.getMenu(this.el);
this.exclusive = true;
@cimi
cimi / analytics-chart.html
Created January 30, 2012 14:37
Size of analytics scripts on mobile sites.
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['corechart']});
</script>
<script type="text/javascript">
function drawVisualization() {
// Create and populate the data table.
var data = new google.visualization.DataTable();
var raw_data = [
@cimi
cimi / CSS.g
Created February 4, 2012 16:30
Grammar Hack Example for Digua
// intialization section
grammar CSS21;
options
{
backtrack=true;
memoize=true;
superClass=DiguaParser;
}
@cimi
cimi / index.html
Last active December 10, 2015 20:08
Demo for the Romania choropleth map generator.
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
@cimi
cimi / provisionr-rundeck-config.sh
Last active December 13, 2015 19:08
Automatically set up a Hadoop cluster provisioned through Axemblr Provisionr and configured through Rundeck.
#!/bin/bash
if [ $# -ne 2 ]; then
echo "The script must take two arguments: namenode internal hostname and current machine internal hostname."
exit 0
fi
# JAVA_HOME is not set by default
sudo sh -c "echo 'export JAVA_HOME=/usr/lib/jvm/java-6-openjdk' >> /etc/profile"
sudo ln -s /usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-openjdk # needed because bigtop-utils do not recognize the prev path
source /etc/profile
@cimi
cimi / import.php
Created April 11, 2013 14:02
Automatically scrape a website and create wordpress posts from its machines.
<pre>
<?php
define('WP_IMPORT_ADMIN', TRUE);
define('TAXONOMY', 'portfolio_category');
require_once( dirname(dirname(__FILE__)) . '/admin.php');
function addThumbnail($url, $name, $post_id) {
$filename = "../../wp-content/uploads/thumbnails/" . strtolower(preg_replace('/(\s\s+)|(\s*[^a-zA-Z0-9]+\s*)/', '-', $name)) . ".jpg";
file_put_contents($filename, file_get_contents($url));
@cimi
cimi / PrimeFactorCalculator.scala
Created June 20, 2013 19:39
Scala coding dojo 20/06/2013 - Code Kata - Prime Factors Calculator http://craftsmanship.sv.cmu.edu/exercises/prime-factors-kata
import java.util
import scala.collection.mutable.ListBuffer
object PrimeFactorCalculator {
def prime(number: Integer):Boolean = {
if (number < 2) return false
if (number == 2) return true
for (i <- 3 to Math.sqrt(number.toDouble).toInt by 2 if (number % i == 0))
return false
true
@cimi
cimi / scala.rb
Last active December 21, 2015 06:59 — forked from JoshRosen/scala.rb
require 'formula'
class ScalaDocs < Formula
homepage 'http://www.scala-lang.org/'
url 'http://www.scala-lang.org/files/archive/scala-docs-2.9.3.zip'
sha1 '633a31ca2eb87ce5b31b4f963bdfd1d4157282ad'
end
class Scala < Formula
homepage 'http://www.scala-lang.org/'
@cimi
cimi / thread_test.py
Last active August 29, 2015 14:19
python threading example
from itertools import groupby
from threading import Thread
from random import randint
from time import sleep
# see http://stackoverflow.com/questions/29291270/threading-in-python-processing-multiple-large-files-concurrently
for key, partition in groupby(range(1, 50), lambda k: k//10):
threads = []
for idx in list(partition):
thread_name = 'thread-%d' % idx