Skip to content

Instantly share code, notes, and snippets.

View majioa's full-sized avatar
🏠
Working from home

Павел "Malo" Скрылёв majioa

🏠
Working from home
View GitHub Profile
@majioa
majioa / downloader.rb
Created January 23, 2013 07:37
Sample downloader tool in Ruby. it reads HTTP or FTP sites from /local/misc/misc/sites and stores results into /local/misc/mirrors.
#!/usr/bin/ruby
require 'net/ftp'
require 'net/http'
require 'fileutils'
class String
def to_l(srcl,dstl)
val = gsub(/(["'\&\(\)])/) { "\\" + $1 }
`echo #{val} |iconv -f #{srcl} -t #{dstl}`.sub(/\n/,"")
end
@majioa
majioa / procmon.rb
Created January 23, 2013 07:23
Simple process monitor tool like `top` in ruby for linux.
#!/usr/bin/ruby
require 'thread'
require 'logger'
$KCODE = "utf-8"
class ProcMon < Logger::Application
def initialize()
super('ProcMon') # Name of the application.
end
@majioa
majioa / capybara cheat sheet
Created November 24, 2015 15:08 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@majioa
majioa / triks.c
Created October 5, 2012 08:21
Some trick on c language
// Detection of an endianness in the run system.
int is_big_endian(void)
{
union {
uint32_t i;
char c[4];
} bint = {0x01020304};
return bint.c[0] == 1;
@majioa
majioa / .bashrc
Created October 1, 2012 11:50
Bash .bashrc sample
# function to convert an mp3 to an ogg file
function mp3_to_ogg {
mp3=$1
wav=$(echo "$mp3"|sed "s/mp3$/wav/i")
ogg=$(echo "$mp3"|sed "s/mp3$/ogg/i")
artist=$(mp3info -p "%a\n" $mp3)
comment=$(mp3info -p "%c\n" $mp3)
genre=$(mp3info -p "%g\n" $mp3)
album=$(mp3info -p "%l\n" $mp3)
track=$(mp3info -p "%n\n" $mp3)
@majioa
majioa / Gemfile
Created September 26, 2012 07:38
Sample function in a post model to share to the post Facebook and Twitter
gem 'koala'
gem 'bitly', '~> 0.8.0'
gem 'twitter'
@majioa
majioa / MainActivity.java
Created July 5, 2012 11:30 — forked from romannurik/SwipeDismissListViewTouchListener.java
**BETA** Android 4.0-style "Swipe to Dismiss" sample code
// THIS IS A BETA! I DON'T RECOMMEND USING IT IN PRODUCTION CODE JUST YET
/*
* Copyright 2012 Roman Nurik
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0