Skip to content

Instantly share code, notes, and snippets.

@abijlani
abijlani / Sieve of Eratosthenes
Created August 29, 2014 22:24
Sieve of Eratosthenes
// Sieve of Eratosthenes
let numbers : Array<Int> = [2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]
func sieve(array: [Int], startIndex: Int) -> [Int] {
let filteredArray = array.filter{(x) -> Bool in
if x == array[startIndex] {
return true
} else {
@abijlani
abijlani / distanceConversion
Created June 5, 2014 21:00
Unit Conversion
enum Unit: Int {
case Millimeters, Centimeters, Meters, Kilometers, Inches, Feet
func baseUnit() -> Double {
switch self {
case .Millimeters:
return 0.001
case .Centimeters:
return 0.01
case .Meters:
@abijlani
abijlani / fizzbuzz
Last active August 29, 2015 14:02
FizzBuzz in Swift
/*
A FizzBuzz written in Swift
Problem: Write a program that prints the numbers from 1 to 20. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".
*/
func isMultipleOf(number: Int, multiple: Int) -> Bool {
return (number % multiple) == 0
@abijlani
abijlani / marshall
Created March 12, 2014 02:25
Marshall
-----BEGIN PGP MESSAGE-----
Version: Keybase OpenPGP JS 0.0.1
Comment: https://keybase.io/crypto
wcFMA/glzC3t0FhJAQ//ZkIvhaJ6e3hqvOT85LE9C5Pat79XXog78qcrO0IyBF9M
+mQme4qk0xPGRJZTyDBvFvHhpnGxJrGNI7x07oz/T2Ppz+jUeOCOQUbYnMtWREG3
a29eZXcSS6Ywm+qvh/weHt2Bv7ftriGlmvcxxH+MFv6C3TqDyc28HZyBPOGQ9Oc6
W/J00K0Ru6APfNfb+snp2fvAeS+lj6IiAIQ4vue1dt/M/EvbYaxbr1Bwd3Xb7gWk
P2Ce1ezUZxOnPWZKxnLOjqv5cZf0PUXP+2irESbVymPXgEQmCt8MFljZke0920AD
UFWKZ3j/k4QwdrUgkVm1ChhXFDvGw+9AG6iqzT73iJc599o8BKyFCPtxliV1nQtx
@abijlani
abijlani / keybase.md
Created March 11, 2014 03:24
keybase.md

Keybase proof

I hereby claim:

  • I am abijlani on github.
  • I am amitbijlani (https://keybase.io/amitbijlani) on keybase.
  • I have a public key whose fingerprint is 2417 853E 2933 9996 3BA2 1D88 2C84 40B1 EC0F 353E

To claim this, I am signing this object:

@abijlani
abijlani / core.php
Created March 2, 2013 18:36
The method within core.php of the JSON API plugin for Wordpress. The core.php file is located within "json-api/controllers"
public function get_recent_summary() {
global $json_api;
$posts = $json_api->introspector->get_posts();
$output = array();
foreach ($posts as $post){
$post_summary["id"] = $post->id;
$post_summary["url"] = $post->url;
$post_summary["title"] = $post->title;
$post_summary["date"] = $post->date;
@abijlani
abijlani / Bank.m
Created August 21, 2012 13:36
Sample Bank Class
@interface Bank
@property (assign, nonatomic) int accountNumber;
@property (assign, nonatomic) float bankBalance;
@end
@implementation Bank