Skip to content

Instantly share code, notes, and snippets.

View afaquejam's full-sized avatar
🚀
Deploying new features, all the time!

Afaque Jamadar afaquejam

🚀
Deploying new features, all the time!
View GitHub Profile
@afaquejam
afaquejam / gist:11296234
Created April 25, 2014 16:58
Re-size images by commands in Ubuntu
sudo apt-get install imagemagick
convert -resize 50% source.png dest.jpg
convert -resize 1024X768 source.png dest.jpg
convert -resize 50% *.png
@afaquejam
afaquejam / Generics.java
Created July 7, 2014 14:42
Java Generics Example
import java.util.ArrayList;
public class Generics<Items> {
private ArrayList<Items> container = new ArrayList<Items>();
public void fillContainer(Items item) {
container.add(item);
}
public void displayContents() {
@afaquejam
afaquejam / callback.c
Created July 7, 2014 14:43
C Function Pointers Example
#include <stdio.h>
int add(int, int);
int substract(int, int);
int perform(int (*doMath)(int, int), int a, int b) {
return doMath(a, b);
}
@afaquejam
afaquejam / Iterator.java
Created July 8, 2014 15:21
Java: Implementing Iterable and Iterator to your Container Class
import java.util.Iterator;
public class Iterators<Items> implements Iterable<Items>{
private class Node {
Items item;
Node next;
}
private Node first = null;
@afaquejam
afaquejam / CustomObject.java
Created July 19, 2014 11:11
Java Comparable Interface
public class CustomObject implements Comparable<CustomObject>{
private int value;
public int compareTo(CustomObject that) {
if(this.value < that.value)
return -1;
else if(this.value > that.value)
return 1;
else
return 0;
@afaquejam
afaquejam / Student.java
Created July 19, 2014 19:02
Java Comparator
// Comparable interface allows us to sort the objects according to the natural
// order. For example, you want to sort a bunch of strings. The natural order
// would be to sort them accroding to their Case sensitivity (Unicode).
// But what if you want to convey a message to the sort algorithm that you want
// to sort the strings in an case insensitive way. The way you do that is by using
// comparators.
// Alright, there are two entities here.
// An class which implements whose objects are to be compared.
@afaquejam
afaquejam / threads.py
Created March 30, 2015 10:59
Threading in Python
import threading
import time
def worker(num, squre):
print ("Worker number: " + str(num))
print ("Squre of the thread number is " + str(squre))
time.sleep(2)
print threading.currentThread().getName()
return
@afaquejam
afaquejam / sublime-text-editor-configuration
Last active August 18, 2019 15:45
Sublime Text Editor Config
{
"color_scheme": "Packages/Color Scheme - Default/Solarized (Light).tmTheme",
"draw_white_space": "all",
"font_size": 12,
"ignored_packages":
[
],
"open_files_in_new_window": true,
"rulers":
[
@afaquejam
afaquejam / Bash - Show Git Branch
Last active August 18, 2019 15:44
Bash - Show Git Branch
# .bashrc
# Insert this line above your prompt setting
function parse_git_branch {
git branch --no-color 2>/dev/null | grep \* | sed "s/\* \(.*\)/ (\1)/"
}
# Change your prompt from whatever it is (for example):
PS1='${USER}@${HOST}:${PWD} > '
# To
@afaquejam
afaquejam / Decorators.py
Last active August 18, 2019 15:44
Python Decorators - 3
################################################
# What are decorators?
# Bascially a wrapper function, which modify the behaviour of a function, without
# changing the functionality of the original function.
# What problem do they actually solve?
# They alter the functionality of a function or a class.
#################################################
# Some original function, whose source we don't want to modify for some reason.