Skip to content

Instantly share code, notes, and snippets.

@kamranzafar
kamranzafar / XORCipher.js
Created October 9, 2016 11:26 — forked from sukima/XORCipher.js
A Super simple encryption cipher using XOR and Base64 in JavaScript
// XORCipher - Super simple encryption using XOR and Base64
//
// Depends on [Underscore](http://underscorejs.org/).
//
// As a warning, this is **not** a secure encryption algorythm. It uses a very
// simplistic keystore and will be easy to crack.
//
// The Base64 algorythm is a modification of the one used in phpjs.org
// * http://phpjs.org/functions/base64_encode/
// * http://phpjs.org/functions/base64_decode/
@kamranzafar
kamranzafar / organize-media.sh
Last active January 1, 2016 07:59
A simple shell script that organizes media files in date folders.
#!/bin/bash
# A simple shell script that organizes media files in date folders.
# This script uses exiftool that can be installed using "sudo apt-get install libimage-exiftool-perl"
for file in *.{jpg,JPG,3gp,3GP,png,PNG,mp4,MP4,mov,MOV};
do
datepath="$(exiftool -s -G "$file" | grep '\[EXIF\].*ModifyDate' | awk '{print $4 }' | sed s%:%/%g)"
if [ -z $datepath ]; then
@kamranzafar
kamranzafar / smh.sh
Last active December 25, 2015 16:39
SVN branch merge helper script
#!/bin/bash
#
# Branch Merge script
#
function usage(){
if [ "$#" -lt 2 ]; then
echo "Usage: $0 <Repository Url> <Branch Name>"
exit 1
@kamranzafar
kamranzafar / asg.sh
Last active December 18, 2015 10:59
#!/bin/sh
# Ad-hoc shell script generator
# Kamran (xeus.man@gmail.com)
# Generates script (default=doit) for the executed commands
# After generation, commands can be re-run using the doit script
echo "Ad-hoc shell script genertor started"
@kamranzafar
kamranzafar / jquery.rest.client.js
Last active December 13, 2015 21:28
JQuery REST Client. A utility class to consume REST services from client side using JQuery.
/*
* JQuery REST Client
* Author: Kamran
* Email: xeus.man@gmail.com
*
* Copyright (C) 2013 Kamran
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
@kamranzafar
kamranzafar / toast.js
Created July 18, 2012 14:40
JQuery Mobile Android-style Toast popup
var toast=function(msg){
$("<div class='ui-loader ui-overlay-shadow ui-body-e ui-corner-all'><h3>"+msg+"</h3></div>")
.css({ display: "block",
opacity: 0.90,
position: "fixed",
padding: "7px",
"text-align": "center",
width: "270px",
left: ($(window).width() - 284)/2,
top: $(window).height()/2 })
@kamranzafar
kamranzafar / ThrottledQueue.java
Created January 31, 2012 22:59
A simple throttled blocking-queue that returns elements at a constant rate (M elements in N time)
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
/**
* A simple throttled blocking-queue that returns elements at a constant rate (M
* elements in N time)
*
@kamranzafar
kamranzafar / doughnut_shop.c
Created January 26, 2012 01:14
A simple Producer-Consumer relationship with POSIX Threads
/*
* Doughnut shop
* A simple Producer-Consumer relationship with POSIX Threads
* author: Kamran
* */
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>