Skip to content

Instantly share code, notes, and snippets.

View Ashu's full-sized avatar
🏠
Working from home

Ashu Ashu

🏠
Working from home
View GitHub Profile
@hausen
hausen / gist:9501041
Last active August 29, 2015 13:57
"Fixing" xkcd 1340 (or making the most redonkulous clock ever)

"Fixing" xkcd 1340 (or making the most redonkulous clock ever)

Update: feeling adventurous? Clone or fork the xkcd clock! If you just want to see it in action or get a glimpse of how it works, keep reading.

Problem

The date in [xkcd's comic number 1340][1] [does not change][2].

#include <curses.h>
#include <stdlib.h>
#include <time.h>
int b[32], *d=&b[16], q, v, y;
char*m[]={
"CBA@GFEDKJIHONML",
"@DHLAEIMBFJNCGKO",
"LHD@MIEANJFBOKGC",
@justecorruptio
justecorruptio / 2048.c
Created April 4, 2014 03:49
Tiny 2048 in C!
M[16],X=16,W,k;main(){T(system("stty cbreak")
);puts(W&1?"WIN":"LOSE");}K[]={2,3,1};s(f,d,i
,j,l,P){for(i=4;i--;)for(j=k=l=0;k<4;)j<4?P=M
[w(d,i,j++)],W|=P>>11,l*P&&(f?M[w(d,i,k)]=l<<
(l==P):0,k++),l=l?P?l-P?P:0:l:P:(f?M[w(d,i,k)
]=l:0,++k,W|=2*!l,l=0);}w(d,i,j){return d?w(d
-1,j,3-i):4*i+j;}T(i){for(i=X+rand()%X;M[i%X]
*i;i--);i?M[i%X]=2<<rand()%2:0;for(W=i=0;i<4;
)s(0,i++);for(i=X,puts("\e[2J\e[H");i--;i%4||
puts(""))printf(M[i]?"%4d|":" |",M[i]);W-2
@staltz
staltz / introrx.md
Last active May 30, 2024 18:43
The introduction to Reactive Programming you've been missing
extension UIImage {
public func imageRotatedByDegrees(degrees: CGFloat) -> UIImage {
let radiansToDegrees: (CGFloat) -> CGFloat = {
return $0 * (180.0 / CGFloat(M_PI))
}
let degreesToRadians: (CGFloat) -> CGFloat = {
return $0 / (180.0 * CGFloat(M_PI))
}
// calculate the size of the rotated view's containing box for our drawing space
@loganwright
loganwright / Contact.swift
Created January 9, 2015 19:03
SwiftContact - Converting ABRecordRef to Clean, usable contact object
//
// Contact.swift
// FriendLender
//
// Created by Logan Wright on 9/22/14.
// Copyright (c) 2014 lowriDevs. All rights reserved.
//
import UIKit
import AddressBook
@JaviLorbada
JaviLorbada / FRP iOS Learning resources.md
Last active May 29, 2024 07:33
The best FRP iOS resources.

Videos

@idiomatic
idiomatic / wwdc.sh
Last active April 10, 2022 03:52
Fetch WWDC videos, slides, and sample code.
#!/bin/bash
# usage: get [ RESOLUTION [ YEAR [ IDS... ] ] ]
resolution=${1:-SD}
year=${2:-2015}
shift
shift
ids=$*
RESOLUTION=$(echo $resolution | tr '[:lower:]' '[:upper:]')
@ditam
ditam / extrapolateFizzBuzz.js
Created August 30, 2015 18:22
fizzbuzz extrapolation function - sample for article at ditam.github.io
function extractPatterns(sample){
var markers = {};
sample.forEach(function(element, i){
if(isNaN( Number(element) )){
var parts = element.split(/(?=[A-Z])/);
parts.forEach(function(part){
if(!markers[part]){
markers[part] = [];
}
markers[part].push(i+1);
@willthink
willthink / contact.m
Last active March 6, 2023 20:05
Using CNContactStore in Objective C to query contacts info
#import <Contacts/Contacts.h>
@implementation ContactsScan
- (void) contactScan
{
if ([CNContactStore class]) {
//ios9 or later
CNEntityType entityType = CNEntityTypeContacts;
if( [CNContactStore authorizationStatusForEntityType:entityType] == CNAuthorizationStatusNotDetermined)