Skip to content

Instantly share code, notes, and snippets.

View sandaru1's full-sized avatar

Sandaruwan Gunathilake sandaru1

View GitHub Profile
@sandaru1
sandaru1 / load_localizations_after_refactor.php
Created September 22, 2017 17:50
Simple script to load localizations from the Main storyboards string into a new one after refactoring some view controllers into a new storyboard using Xcode 9.
<?php
/*
Make sure to localize the new storyboard files using Xcode and that should be used as the destination.
*/
$src = file($argv[1]);
$dst = file($argv[2]);
$modified_file = array();
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
#define SPLIT_SIZE 1024 * 1024 * 1024
int main (int argc, char *argv[]) {
if (argc<2) {
#!/bin/bash
mac=68:a8
mac0=`openssl rand -hex 1`
mac1=`openssl rand -hex 1`
mac2=`openssl rand -hex 1`
mac3=`openssl rand -hex 1`
final=$mac:$mac0:$mac1:$mac2:$mac3
ifconfig en1 ether $final
@sandaru1
sandaru1 / facebook.user.js
Created February 15, 2012 15:30
Facebook link cleaner
// ==UserScript==
// @name Facebook link cleaner
// @description Remove facebook link mousedown events that sends you to news site's facebook app instead actual content. Based on "http://userscripts.org/scripts/review/125355"
// @include http://www.facebook.com/*
// @include https://www.facebook.com/*
// @version 1.0
// ==/UserScript==
function stripit(links) {
for (var i=0; i<links.length; i++) {
@sandaru1
sandaru1 / gist:918030
Created April 13, 2011 18:02
count tweets
page="`curl 'http://search.twitter.com/search.atom?q=sajje+since%3A2011-04-13&rpp=100'`"
next="test"
all=""
while [ "$next" != "" ]; do
all="$all
`echo "$page" | grep '<name>' | sed 's/<name>\(.*\)<\/name>/\1/' | awk '{print $1}'`"
next=`echo "$page" | grep -o -e '<link type=\"application\/atom+xml\" href\=\"[^\"]*\" rel=\"next\"/>' | sed 's/.*href="\([^"]*\)".*/\1/' | sed 's/\&amp;/\&/g'`
if [ "$next" != "" ]; then
page=`curl $next`
fi
<?php
class Notifo_API {
const API_ROOT = 'https://api.notifo.com/';
const API_VER = 'v1';
protected $apiUsername;
protected $apiSecret;
from urlparse import urlparse
import csv
f = csv.reader(open('fixed.csv'))
domains = {}
counts = {}
used = {}
for row in f:
if (row[9] not in used):
import csv
f = open('trends.csv')
writer = csv.writer(open("fixed.csv", "wb"))
def valid(x): return (x!="," and x!="" and x!="\r\n");
def remove_new(x): return x.replace("\r\n","")
lines = ""
for line in f: