Skip to content

Instantly share code, notes, and snippets.

View isqad's full-sized avatar
:shipit:
Working from home

Andy0x58 isqad

:shipit:
Working from home
  • Ekaterinburg, Russia
  • 00:00 (UTC +05:00)
View GitHub Profile
@isqad
isqad / crawler.js
Created May 24, 2012 11:11
crawler
var http = require('http');
var events = require('events');
var jsdom = require('jsdom');
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/crawler');
var Schema = mongoose.Schema;
var ObjectId = Schema.ObjectId;
@isqad
isqad / erlang-db.erl
Created March 25, 2013 06:17
Simple database
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Database base on list set %
% Andrew N. Shalaev %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-module(db).
-export([start/0, stop/0, read/1, write/2, delete/1]).
-export([init/0]).
% process loop
@isqad
isqad / hash_table.rb
Last active December 25, 2015 18:29
# связанный список
class SeqList
attr_accessor :first
class Node
attr_accessor :key, :val, :next_node
def initialize(key, val, next_node)
@key, @val, @next_node = key, val, next_node
@isqad
isqad / Gemfile
Last active August 29, 2015 14:20 — forked from yuki24/Gemfile
source 'https://rubygems.org'
gem 'benchmark-ips'
gem 'activesupport'
gem 'jbuilder'
gem 'rabl'
gem 'oj'
company_id = 11973147
wrong_field = :active_reviews_count
# before
CoreDenormalization::Fields::Company::Reviews.value_as_string(object: company_id, field: wrong_field)
sql_for_data = initialize_statement # with company_id filter
data = ActiveRecord::Base.connection.execute sql_for_data
hash_with_object_key = {data.delete(:object_id) => data}
CoreDenormalization::Fields::Company::Reviews.instance.write_data hash_with_object_key
@isqad
isqad / App.java
Created May 31, 2015 08:14
Maximum integer from integer array of any length
package ru.cohab;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
public class App {
public static final int COUNT = 4;
public static void main(String[] args) throws Exception {
build_package_patch_ruby_railsexpress() {
fetch_git rvm-patchsets git://github.com/skaes/rvm-patchsets.git master
for p in rvm-patchsets/patches/ruby/1.9.3/p551/railsexpress/* ; do
patch -p1 < $p
done
}
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
install_package "ruby-1.9.3-p551" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p551.tar.gz" patch_ruby_railsexpress autoconf standard
@isqad
isqad / power_of_thor.clj
Last active October 4, 2015 13:31
CodinGame - my learning #clojure lang
(ns Player
(:gen-class))
; Auto-generated code below aims at helping you parse
; the standard input according to the problem statement.
; ---
; Hint: You can use the debug stream to print initialTX and initialTY, if Thor seems not follow your orders.
(defn -main [& args]
@isqad
isqad / chuck-norris-encoding.clj
Last active November 22, 2015 19:08
Solution for "Chuck Norris" exercise of CodinGame.com
(ns Solution
(:gen-class))
(defn int-to-bin
"Converts integer to binary"
[n]
(reverse (cond
(= n 1) [1]
(= n 0) [0]
:else (loop [q (quot n 2)
@isqad
isqad / renamer.clj
Last active November 29, 2015 11:48
Renames file list in reverse order
(ns renamer.core
(:gen-class)
(:require [clojure.java.io :as io]))
(defn file-list
[path]
(->
path
(io/file)
(.listFiles)