Skip to content

Instantly share code, notes, and snippets.

View azmfaridee's full-sized avatar
🎯
Focusing

Abu-Zaher Faridee azmfaridee

🎯
Focusing
View GitHub Profile
@azmfaridee
azmfaridee / Maven.sublime-build
Created August 16, 2015 19:07
Simple "Maven" Build System for Sublime Text 3
{
"shell_cmd": "mvn clean compile",
"working_dir": "${project_path:${folder}}",
"variants": [
{
"name": "Run Tests",
"shell_cmd": "mvn test"
},
{
"name": "Run in Tomcat 7",
@azmfaridee
azmfaridee / Repeat.java
Last active August 29, 2015 14:12 — forked from fappel/Repeat.java
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention( RetentionPolicy.RUNTIME )
@Target( {
java.lang.annotation.ElementType.METHOD
} )
public @interface Repeat {
public abstract int times();
@azmfaridee
azmfaridee / objc-blocks-in-array.mm
Created August 14, 2013 18:24
Example of storing Objective-C blocks in an array. The example assumes ARC, no memory cleanup. Note that when adding the 'block' to the `NSMutableArray` you need to use the `copy` message (regardless of using ARC).
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
{
NSMutableArray *array = [NSMutableArray array];
for (int i = 0; i < 5; i++) {
[array addObject:[^() {
NSLog(@"I have Value of %d", i);
} copy]];
}
@azmfaridee
azmfaridee / objc-blocks.mm
Created August 14, 2013 17:38
A demonstration of using closures in Objective C. In Objective C terminology, it's called 'Blocks' instead of closures. Here I'm creating a 'block' that can create other 'blocks' by supplying a parameter. I run this in XCode 4.6 and Mac OS X 10.8. I had ARC turned on while I was coding this, but I think it's not a must for this particular exampl…
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
{
int (^(^makeAdder)(int))(int) = ^(int toAdd) {
int (^fn)(int) = ^(int arg) {
return toAdd + arg;
};
return fn;
};
@azmfaridee
azmfaridee / function_generator.cpp
Created August 5, 2013 13:22
Using C++11's lambda to generate desired functions with a factory.
#include <iostream>
#include <vector>
std::function<float(float)> converter_factory(std::string region) {
if (region == "US") {
return [] (float celsius) -> float {
return (celsius / 5 * 9 + 32);
};
}
return [] (float fahrenheit) -> float {
@azmfaridee
azmfaridee / closure.cpp
Created August 5, 2013 06:33
A simple example of closures in C++11. Also shows how you can keep a vector of 'functors'. You'd need a C++11 compatible compiler, I wrote and compiled this in XCode 4.6.3 :)
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, const char * argv[]) {
vector<function<void()>> functions;
for (int i = 0; i < 5; i++) {
functions.push_back([i] () {
@azmfaridee
azmfaridee / colors.json
Created July 14, 2013 19:55
Named colors in JSON format
{
"aliceblue":"#F0F8FF",
"antiquewhite":"#FAEBD7",
"aquamarine":"#7FFFD4",
"azure":"#F0FFFF",
"beige":"#F5F5DC",
"bisque":"#FFE4C4",
"black":"#000000",
"blanchedalmond":"#FFEBCD",
"blue":"#0000FF",
[
{
"hex": "#EFDECD",
"name": "Almond",
"rgb": "(239, 222, 205)"
},
{
"hex": "#CD9575",
"name": "Antique Brass",
"rgb": "(205, 149, 117)"
#!/usr/bin/python
# coding=utf-8
# -*- encoding: utf-8 -*-
import sys, codecs, copy, commands;
sys.stdin = codecs.getreader('utf-8')(sys.stdin);
sys.stdout = codecs.getwriter('utf-8')(sys.stdout);
sys.stderr = codecs.getwriter('utf-8')(sys.stderr);
#!/usr/bin/python
# coding=utf-8
# -*- encoding: utf-8 -*-
import sys;
# À Bunifaziu si cunserva l'usu di una varietà di a lingua ligura [[Dialettu bunifazincu|bunifazinca]], un dialettu ghjinuvesu arcaicu chì currispondi à a parlata impurtata da i culoni à a fini di u XIIIimu seculu.
# Si stima chì u corsu sia parlatu in [[Corsica]] da circa 90/100.000 lucutori frà i 275.000 abitanti di l'isola, puru ch'elli sianu parechji frà quessi à esse di lingua materna francese (dati da una ricerca di l'INSEE di u 2004 [http://www.insee.fr/fr/insee_regions/corse/rfc/docs/ecoc1053.htm]), à quelli ci hè quantunque da aghjustà e pupulazione emigrate in [[Francia]] (par un tutale di 133.000 individui in Francia) è in altre nazione.
urls = [];