Skip to content

Instantly share code, notes, and snippets.

View r00takaspin's full-sized avatar

Voldemar Duletskiy r00takaspin

View GitHub Profile
@r00takaspin
r00takaspin / safe_runtime
Created October 31, 2014 09:38
$SAFE in action
puts "unsafe"
$SAFE = 0
eval ("#{gets()}")
puts "safe"
$SAFE = 1
@r00takaspin
r00takaspin / vsftpd.conf
Created March 2, 2015 15:21
VSFTPD configuration at Amazon EC2
# Example config file /etc/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
class Alex
attr_accessor :users
def initialize
@users = []
end
def add_user(user)
@users << user
#БЫЛО
tier1.uniq_by!(&:id).sort_by! { rand }.sort_by! {|x| x.avatar_file_name.blank? ? 1 : 0} +
tier2.uniq_by!(&:id).sort_by! { rand }.sort_by! {|x| x.avatar_file_name.blank? ? 1 : 0} +
tier3.uniq_by!(&:id).sort_by! { rand }.sort_by! {|x| x.avatar_file_name.blank? ? 1 : 0} +
(instructors - tier1 - tier2 - tier3).uniq_by!(&:id).sort_by! { rand }.sort_by! {|x| x.avatar_file_name.blank? ? 1 : 0}
#СТАЛО
instructors = [tier1,tier2,tier3].inject {|result, x| result + tier_filter(x) } +
tier_filter(instructors - tier1 - tier2 - tier3)
#!/bin/sh
# This script will migrate schema and data from a SQLite3 database to PostgreSQL.
# Schema translation based on http://stackoverflow.com/a/4581921/1303625.
# Some column types are not handled (e.g blobs).
SQLITE_DB_PATH=$1
PG_DB_NAME=$2
PG_USER_NAME=$3
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_DATA 100
struct StackElement {
struct StackElement *head;
char data[MAX_DATA];
};
create_project = ::Panels::Prodege::Client::Requests::CreateProject
request = create_project.new(
project_id,
country_id: country_id,
project_url: project_url,
cpi: cpi,
loi: loi,
project_name: project_name
)
some_function(From) -> From ! { reply, "Greetings" } end.
P = spawn(some_function(self())),
receive
  {reply, Msg} -> Msg,
  Msg -> io:format("~p~n", [Msg])
after 5000 -> timeout
end.
require 'benchmark'
require 'digest'
require 'etc'
THREAD_NUMBER = Etc.nprocessors
def count_md5(id)
tmp = id.to_s
1_000_000.times { tmp = Digest::MD5.hexdigest(tmp) }
tmp
#include <stdlib.h>
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
pthread_mutex_t lock;
int counter = 0;
#define MAX_ITER 100000