Skip to content

Instantly share code, notes, and snippets.

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

Reza r6m

🏠
Working from home
  • localhost
View GitHub Profile
@r6m
r6m / ps_mem.py
Last active November 5, 2015 10:05
shows the real memory usage in MB ubuntu
#!/usr/bin/env python
# Try to determine how much RAM is currently being used per program.
# Note per _program_, not per process. So for example this script
# will report RAM used by all httpd process together. In detail it reports:
# sum(private RAM for program processes) + sum(Shared RAM for program processes)
# The shared RAM is problematic to calculate, and this script automatically
# selects the most accurate method available for your kernel.
# Licence: LGPLv2
#!/bin/sh
### BEGIN INIT INFO
# Provides: puma app runner
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the puma web server
# Description: starts the puma web server
@r6m
r6m / gist:c3a4e8ffd1b3a47c4423
Created November 13, 2015 15:05
Virtualbox how to set up a shared folder
1. Make sure you have guest addons installed.
for example : "c:\www\dev"
2. On host, select the share you want to share and remember what it's called. Its real path does not matter! So let's say your share is called dev.
3. Launch virtual machine guest. In terminal, type:
$ cd /mnt
$ sudo mkdir shares
$ sudo mount -t vboxsf dev shares
And that's it. Don't worry about the absolute paths. You don't need them. For all practical purposes, VB will take care of the real path behind the share name, in this case Dedoimedo.
@r6m
r6m / backup.sh
Created November 27, 2015 06:00
generate backup model
$ backup generate:model --trigger backup_name\
--databases="mysql" --storages="dropbox" \
--compressor="gzip" --notifiers="mail"
@r6m
r6m / install_mcrypt_php
Last active January 2, 2017 10:52
how to enbale mcrypt php-mcrypt
sudo apt-get install php5-cli php5-fpm php5-mcrypt
sudo php5enmod mcrypt
sudo service php5-fpm restart
@r6m
r6m / https-get-params-ruby.rb
Created January 5, 2016 05:13
https get with param using Net::HTTP
#! /usr/bin/env ruby
require 'net/http'
require 'uri'
require 'cgi'
mode = 'prod'
id = '000000'
new = 'true'
@r6m
r6m / *.bat
Created January 30, 2016 18:51 — forked from michfield/*.bat
Install Gems without documentation #ruby #windows
:: Make --no-ri --no-rdoc default gem install options (without documentation)
:: Possible variations:
:: For every user:
:: echo gem: --no-ri --no-rdoc > "%PROGRAMDATA%\gemrc"
:: Only for you
:: echo gem: --no-ri --no-rdoc >> "%USERPROFILE%\.gemrc"
::
:: Note: In Windows, %PROGRAMDATA% is /etc on Linux
::
:: But finally, the best way to do it. See: http://stackoverflow.com/a/7662245/1579985
@r6m
r6m / 0_reuse_code.js
Created January 2, 2017 10:45
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@r6m
r6m / serializer.rb
Created January 2, 2017 10:50
yet another simple serializer for ruby class. you can also access to attr_accessor variable names
module Serializer
def serializables
self.class.instance_variable_get('@serializables')
end
def attr_accessors
self.class.instance_variable_get('@attr_accessors')
end
def self.included(klass)
@r6m
r6m / bash.sh
Created February 25, 2017 13:34
get images from video using ffmpeg
ffmpeg -r 10 -f image2 -s 1920x1080 -i %04d.png -vcodec libx264 -crf 25 -pix_fmt yuv420p test.mp4
# -r is the framerate (fps)
# -i %04d.png (example 0001.png, 0002.png)
# -crf is the quality, lower means better quality, 15-25 is usually good
# -s is the resolution
# -pix_fmt yuv420p specifies the pixel format, change this as needed