Skip to content

Instantly share code, notes, and snippets.

****
gpg ( configure your gpg settings )
curl -sSL https://rvm.io/mpapis.asc | sudo gpg --import -
curl -L https://get.rvm.io | sudo bash -s stable --rails
rvm requirements, which ruby, rails -v ( test RVM, Ruby and Rails )
***
@pankzid
pankzid / flvxz.py
Created November 5, 2015 10:53 — forked from misawachitose/flvxz.py
簡易的 flvxz.com 網站解析工具
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import urllib2
from base64 import b64encode
from BeautifulSoup import BeautifulStoneSoup
Help = """A tool for fetch flvxz.com video URL parse result.
@pankzid
pankzid / init.bat
Last active August 29, 2015 14:13 — forked from 17/init.bat
@echo off
SET CMDER_ROOT=%~dp0
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Cmder" /ve /d "Cmder Here" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Cmder" /v "Icon" /d "\"%CMDER_ROOT%cmder.exe\"" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Cmder" /v "Extended" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Cmder\command" /ve /d "\"%CMDER_ROOT%cmder.exe\" \"%%V\"" /f
pause
@pankzid
pankzid / gist:44e50dde719fe2f51a33
Created September 14, 2014 16:32
oop - Learning to think in the Object Oriented Way
I've been doing software development with OO for over 20 years now, and I can tell you that looking at other peoples code is more often than not going to teach you how to do procedural programming in an object oriented language.
What I would recommend is to use the following techniques, which if applied liberally, will force you to use OO techniques, even though you may not yet be aware of them.
Do not copy and paste code - ever.
Create classes that represent the things you talk about when talking about the functionality - for example, an order entry system will have Orders, Customers, Accounts, OrderItems, InventoryItems, etc.
When creating these classes, do NOT code any public set and get methods to access the class data members.
Add methods to these domain model classes that perform the work on the object in question. Order.invoice(), account.close(), InventoryItem.decrement(). The lack of public get methods will show you the correct location for the code (where the data is - in the app
@pankzid
pankzid / gist:2470691f37b25bcca12c
Created August 28, 2014 05:26
totem - ubuntu - delete recent file
If you want to permanently remove the recent file list from totem, edit /usr/share/totem/totem.ui as root and change to following line:
<separator name="recent-separator"/>
<placeholder name="recent-placeholder"/>
into
<!--<separator name="recent-separator"/>
<placeholder name="recent-placeho
@pankzid
pankzid / gist:68aded25f33c6c115327
Created August 27, 2014 07:02
php - singleton oop
Unfortunately Inwdr's answer breaks when there are multiple subclasses.
Here is a correct inheritable Singleton base class.
class Singleton
{
private static $instances = array();
protected function __construct() {}
@pankzid
pankzid / gist:0bd4ab9b5547b369161b
Last active August 29, 2015 14:05 — forked from anonymous/gist:bb5f91f4f78a3b322d34
rails - imagemagick_paperclip resizing style option
"#" is an argument used by Paperclip to know whether or not you expect the pic to be cropped. Using "100x100#" will scale and crop the picture exactly to that size. %@!<> are arguments in the Geometry String used by ImageMagick. One can use the following ImageMagick geometry strings for resizing images:
Ignore Aspect Ratio ('!')
Only Shrink Larger ('>')
Only Enlarge Smaller ('<')
Fill Given Area ('^')
Percentage Resize ('%')
Pixel Count Limit ('@')
UPDATE for rails 3.2.12:
I just checked the source and the dependencies are like this now:
db:create creates the database for the current env
db:create:all creates the databases for all envs
db:drop drops the database for the current env
db:drop:all drops the databases for all envs
db:migrate runs migrations for the current env that have not run yet
db:migrate:up runs one specific migration
@pankzid
pankzid / gist:307f4679b02a38e3ee23
Last active August 29, 2015 14:04
rails-devise: add user with console
When on your model has :confirmable option this mean the object user should be confirm first. You can do two ways to save user.
a. first is skip confirmation:
newuser = User.new({
email: 'superadmin1@testing.com',
password: 'password',
@pankzid
pankzid / gist:11405588
Created April 29, 2014 16:37
mysql - backup and restore MySQL Database Using mysqldump
Backup Semua Database
Ada beberapa cara yang bisa dilakukan untuk melakukan backup database di MySQL. Berikut adalah artikel mengenai penggunaan MySQLDump.
Menggunakan MYSQLDUMP
mysqldump adalah utilitas client yang datang bersama distribusi MySQL. Aplikasi ini akan menghasilkan script SQL di console, sehingga bisa didump ke file melalui IO pipe.
Berikut adalah contoh-contoh penggunaan mysqldump untuk backup database :
Backup semua database - struktur dan data
mysqldump -uusername -ppassword -A