Skip to content

Instantly share code, notes, and snippets.

@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)
@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"
<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 / 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);
}
@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 / 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 / gist:3794449
Created September 27, 2012 14:53
simple API security
before_filter :restrict_access
protected
def restrict_access
if Rails.env != "development"
access_token = request.headers['access_token']
access_token ||= params[:access_token]
begin
@auth = Authorization.find_by_access_token(access_token)
-////////////////////////////////////////////////////////////////////////////////////
- UIImage *maskImg = [UIImage imageNamed:@"Ethics-Risk-Triangle.png"];
- CGImageRef maskRef = maskImg.CGImage;
-
- CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef),
- CGImageGetHeight(maskRef),
- CGImageGetBitsPerComponent(maskRef),
- CGImageGetBitsPerPixel(maskRef),
- CGImageGetBytesPerRow(maskRef),
- CGImageGetDataProvider(maskRef), NULL, false);
@andrei512
andrei512 / code.rb
Created September 20, 2012 14:12
comments
def reactions
@article = Article.find(params[:article_id])
comments = @article.comments.includes(:user)
emotions = @article.emotions.includes(:user)
reactions = comments + emotions
reactions.sort! { |x, y|
y.created_at <=> x.created_at
@andrei512
andrei512 / facepile.json
Created September 14, 2012 10:56
sample facepile JSON
{
"faces" : ["https://si0.twimg.com/profile_images/1860046271/image_normal.jpg",
"https://si0.twimg.com/profile_images/2518045421/image_normal.jpg",
"https://si0.twimg.com/profile_images/2452768851/bhd68fvfnr5k0micbpcz_normal.jpeg",
"https://si0.twimg.com/profile_images/1824002576/pg-railsconf_normal.jpg",
"https://si0.twimg.com/profile_images/1620281242/Screen_shot_2011-11-03_at_1.11.35_PM_normal.png",
"https://si0.twimg.com/profile_images/1884069342/BGtwitter_normal.JPG",
"https://si0.twimg.com/profile_images/1766054826/cristian_normal.jpg",
"https://si0.twimg.com/profile_images/2235748695/mrtall_white_bg_normal.png"
],