Skip to content

Instantly share code, notes, and snippets.

@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
use Rack::Static,
:urls => ["/images", "/js", "/css", "/public"],
:root => "public"
require './webserver.rb'
run KoderWSApp.new
@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
#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 / 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"
@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 / NSURLRequest+cURL.h
Created January 6, 2014 13:20
NSURLRequest+cURL
#import <Foundation/Foundation.h>
@interface NSURLRequest (cURL)
- (NSString *)cURLCommand;
@end
DERIVED_DATA_PATH = "~/Library/Developer/Xcode/DerivedData/"
def projects
`ls -al #{DERIVED_DATA_PATH}`.split("\n")[3..-1].map { |p|
ls_components = p.split(" ")
project_name = ls_components.last
if project_name != "ModuleCache"
project_name = project_name.split("-")[0..-2].join("-")
else
@andrei512
andrei512 / hack.m
Created January 10, 2014 11:47
hack for preventing multiple method calls in the same time. For example if you have a bug in your code that calls viewWillAppear: two times every time you can just copy/paste this code
// Invalidate a call if it's been less that 1 second since the last one
//=====================================================================
static NSDate *lastDate = nil;
NSDate *currentDate = [NSDate date];
if (lastDate != nil &&
[currentDate timeIntervalSinceDate:lastDate] < 1) {
return ;
}
lastDate = currentDate;
//=====================================================================
@andrei512
andrei512 / ubiquitous.rb
Created January 16, 2014 15:48
ubiquitous ruby clipboard processing script
#!/usr/bin/env ruby
clipboard = `pbpaste`
if clipboard.match /https?:\/\/w?w?w?\.((youtube)|(listenonrepeat))\.com\/.*/
# Youtube / Listen on repeat
if clipboard["youtube"] != nil
clipboard["youtube"] = "listenonrepeat"
elsif clipboard["listenonrepeat"] != nil
clipboard["listenonrepeat"] = "youtube"
end