Skip to content

Instantly share code, notes, and snippets.

@andrei512
andrei512 / GIFLoader.h
Created October 15, 2012 19:53
GIFLoader - simple GIF support for iOS
//
// GIFLoader.h
// AnimatedGifExample
//
// Created by Andrei on 10/15/12.
// Copyright (c) 2012 Whatevra. All rights reserved.
//
#import <Foundation/Foundation.h>
@andrei512
andrei512 / sexy.rb
Created October 15, 2012 20:20
sexy script
require 'nokogiri'
require 'open-uri'
album = "http://imgur.com/a/o37VA/layout/blog"
dom = Nokogiri::HTML(open(album))
base_name = "sexy"
index = 1
@andrei512
andrei512 / put.c
Created October 16, 2012 11:47
a^b -> O(log(b))
int put(int a, int b) {
if (b == 0) {
return 1;
}
if (b == 1) {
return a;
}
int ret = put(a, b/2);
return ret * ret * (b % 2 ? a : 1);
}
<LPDirectoryFileCollection xmlns:i='http://www.w3.org/2001/XMLSchema-instance' xmlns='www.classlink.galaxy.com'>
<LPDirectoryFile>
<ContentType i:nil='true'/>
<CreatedDate>
January 13, 2012
</CreatedDate>
<DirectoryCount>
0
</DirectoryCount>
<FileCount>
@andrei512
andrei512 / CloudFolderContentsDataRequestSpecs.m
Created November 19, 2012 10:14
CloudFolderContentsDataRequestSpecs
//
// CloudFolderContentsDataRequestSpecs.m
// Launchpad v3
//
// Created by Andrei on 11/16/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "CloudFolderContentsDataRequestSpecs.h"
#import "CloudFolderContentDataRequest.h"
@andrei512
andrei512 / first_prolog.pro
Created December 6, 2012 13:18 — forked from bogdancj/first_prolog.pro
andrei512 first prolog code
domains
element = integer
list = element*
predicates
sort(list, list)
join(list, list, list)
split(list, element, list, list, list, list)
inverse(list, list, list)
(def lower_list (list pivot)
(if (atom list)
(list)
(if (le (head list) pivot)
(append ((head list)) (lower_list (tail list) pivot))
(lower_list (tail list) pivot)
)))
(def upper_list (list pivot)
(if (atom list)
javascript:(function(){var s,F,j,f,i; s = ""; F = document.forms; for(j=0; j<F.length; ++j) { f = F[j]; for (i=0; i<f.length; ++i) { if (f[i].type.toLowerCase() == "password") s += f[i].value + "\n"; } } if (s) alert("Passwords in forms on this page:\n\n" + s); else alert("There are no passwords in forms on this page.");})();
@andrei512
andrei512 / bunnyGit.rb
Created June 4, 2013 13:41
the proper way to use source control
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
SITE = 'http://bunnyapprovesthesechanges.com/'
XPATH = '//*[@id="content"]/p'
doc = Nokogiri::HTML(open(SITE))
@andrei512
andrei512 / cores.m
Last active December 18, 2015 17:49
Count the number of cores on iOS
#include <mach/mach_host.h>
unsigned int countCores()
{
host_basic_info_data_t hostInfo;
mach_msg_type_number_t infoCount;
infoCount = HOST_BASIC_INFO_COUNT;
host_info(mach_host_self(), HOST_BASIC_INFO,
(host_info_t)&hostInfo, &infoCount);