Skip to content

Instantly share code, notes, and snippets.

@andrei512
andrei512 / ubiruby.rb
Last active January 2, 2016 07:39
the ubiquitous ruby hack
#!/usr/bin/env ruby
clipboard = `pbpaste`
begin
output = eval(clipboard)
`echo #{output} | pbcopy`
rescue Exception => e
# silence exception
end
@andrei512
andrei512 / dict.cc.rb
Created January 4, 2014 20:15
dict.cc API ... ish
require 'open-uri'
require 'nokogiri'
require 'json'
def search word
open("http://www.dict.cc/?s=#{word}").read
end
keyword = ARGV.count > 0 ? ARGV.join(" ") : "stein"
#include <stdio.h>
#include <stdlib.h>
/*3.6. De pe mediul de intrare se citeşte un număr natural n. Să se
verifice dacă numărul respectiv este palindrom.
*/
int main()
{
int n,ninv,aux;
printf("introduceti numarul: ");
scanf("%d",&n);
@andrei512
andrei512 / ruby.sh
Created December 9, 2013 12:35
install ruby
# Update APT package index
sudo apt-get update
# Install prerequisites
sudo apt-get install -y git curl zlib1g-dev subversion
sudo apt-get install -y openssl libreadline6-dev git-core zlib1g libssl-dev
sudo apt-get install -y libyaml-dev libsqlite3-dev sqlite3
sudo apt-get install -y libxml2-dev libxslt-dev
sudo apt-get install -y autoconf automake libtool bison
use Rack::Static,
:urls => ["/images", "/js", "/css", "/public"],
:root => "public"
require './webserver.rb'
run KoderWSApp.new
@andrei512
andrei512 / cleverbot.rb
Created September 22, 2013 02:59
cleverbot talking with cleverbot
require 'cleverbot'
@client1 = Cleverbot::Client.new
@client2 = Cleverbot::Client.new
def say message, voice="Vicki"
puts message
`say -v #{voice} "#{message}"`
end
@andrei512
andrei512 / APRuntime.json
Last active December 22, 2015 18:09
runtime_doc.rb
[
{
"name": "class_addIvar",
"abstract": "Adds a new instance variable to a class. ",
"abstract_xml": "<p class=\"abstract\">Adds a new instance variable to a class. </p>\n",
"declaration": "\nBOOL class_addIvar(Class cls, const char *name, size_t size, uint8_t alignment, const char *types)\n",
"declaration_xml": "<pre class=\"declaration\">\nBOOL class_addIvar(Class cls, const char *name, size_t size, uint8_t alignment, const char *types)\n</pre>\n",
"return_value": "Return ValueYES if the instance variable was added successfully, otherwise NO (for example, the class already contains an instance variable with that name).",
"return_value_xml": "<div class=\"return_value\">\n<h5 class=\"tight\">Return Value</h5>\n<p><code>YES</code> if the instance variable was added successfully, otherwise <code>NO</code> (for example, the class already contains an instance variable with that name).</p>\n</div>",
"api_discussion": "DiscussionThis function may only be called after objc_allocat
@andrei512
andrei512 / metamacros.c
Created September 9, 2013 19:11
metamacros 101 :P
/**
* Macros for metaprogramming
* ExtendedC
*
* Copyright (C) 2012 Justin Spahr-Summers
* Released under the MIT license
*/
#ifndef EXTC_METAMACROS_H
#define EXTC_METAMACROS_H
@andrei512
andrei512 / gist:6306023
Created August 22, 2013 11:22
The true Objective-C singleton
+ (id)alloc {
static dispatch_once_t onceToken;
static SettingsViewController *singleton = nil;
dispatch_once(&onceToken, ^{
singleton = [super alloc];
});
return singleton;
}
- (id)init {
javascript: alert($('#_ctl3_uphone_uphwl').css('color'))