Skip to content

Instantly share code, notes, and snippets.

View r00takaspin's full-sized avatar

Voldemar Duletskiy r00takaspin

View GitHub Profile
#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
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
@r00takaspin
r00takaspin / puma.service
Created May 11, 2018 15:29
Run puma web server with RVM from systemd
[Unit]
Description=Puma HTTP Server
After=network.target
# Uncomment for socket activation (see below)
# Requires=puma.socket
[Service]
# Foreground process (do not use --daemon in ExecStart or config.rb)
Type=simple
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.
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
)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_DATA 100
struct StackElement {
struct StackElement *head;
char data[MAX_DATA];
};
#БЫЛО
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)
class Alex
attr_accessor :users
def initialize
@users = []
end
def add_user(user)
@users << user
@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.
#
@r00takaspin
r00takaspin / safe_runtime
Created October 31, 2014 09:38
$SAFE in action
puts "unsafe"
$SAFE = 0
eval ("#{gets()}")
puts "safe"
$SAFE = 1