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",
@Ashu
Ashu / sc-dl.js
Created March 9, 2012 13:58 — forked from pheuter/sc-dl.js
Bookmarklet that generates download link for a Soundcloud upload
(function(d) {
var dl = d.createElement('a');
dl.innerText = 'Download MP3';
dl.href = "http://media.soundcloud.com/stream/"+d.querySelector('#main-content-inner img[class=waveform]').src.match(/\.com\/(.+)\_/)[1];
dl.download = d.querySelector('em').innerText+".mp3";
d.querySelector('.primary').appendChild(dl);
dl.style.marginLeft = '10px';
dl.style.color = 'red';
dl.style.fontWeight = 700;
})(document);
@volodg
volodg / gist:5531956
Last active December 19, 2015 13:40
objc_getAssociatedObject example
#include <objc/runtime.h>
static char dynamicPropertyKey;
@interface TestClass (ParseObject)
@property (nonatomic) NSObject *dynamicProperty;
@end
import UIKit
// Swift rewrite challenge
// Starting point: https://gist.github.com/jkereako/200342b66b5416fd715a#file-scale-and-crop-image-swift
func scaleAndCropImage(
image: UIImage,
toSize size: CGSize,
fitImage: Bool = true
) -> UIImage {
@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
//
// CJCAnonymousFacesFilter.h
// CJC.FaceMaskingDemo
//
// Created by Chris Cavanagh on 11/9/13.
// Copyright (c) 2013 Chris Cavanagh. All rights reserved.
//
#import <CoreImage/CoreImage.h>
@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);
import Foundation
import UIKit
@IBDesignable
class DesignableView: UIView {
}
@IBDesignable
class DesignableButton: UIButton {
}
@Nanomancer
Nanomancer / transmission.rb
Last active December 1, 2019 13:17
Sonic Pi code (Ruby) for piece entitled 'Transmission' based around MIDI note tuned resonators
## Transmission - Origin Unknown -Tuned Resonators in C minor
## Random Seed Version: 746742
## Coded by Nanomancer - Distributed under Creative Commons Non-Commercial Attribution license - :)
## 26.03.2016
## Watch a video produced with screen grabs of the code and Nebulae:
## https://www.youtube.com/watch?v=5fwGHAdoaXA&feature=youtu.be
#######################
max_t = 8 # Adjust the run time of the piece