Skip to content

Instantly share code, notes, and snippets.

View letsspeak's full-sized avatar
🥺
finding remote jobs

Masatsugu Omiya letsspeak

🥺
finding remote jobs
View GitHub Profile
@letsspeak
letsspeak / sync-charag
Created July 30, 2012 00:35
immediately rsync when the file in specific directory was written by vim (final edition)
#!/bin/sh
rsync -av -e "ssh -p XXXX" $1 XXXX@charag.jp:$2
@letsspeak
letsspeak / gist:3950545
Created October 25, 2012 05:26
NSUInteger(unsigned int) subtraction results
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSUInteger a = 5, b = 10;
NSInteger c = 8;
NSLog(@" a - b = %d", a - b);
// a - b = -5
@letsspeak
letsspeak / database.yml
Created October 30, 2012 17:41
Redmine on unicorn on nginx with mysql, my configuration files.
# Default setup is given for MySQL with ruby1.8. If you're running Redmine
# with MySQL and ruby1.9, replace the adapter name with `mysql2`.
# Examples for PostgreSQL and SQLite3 can be found at the end.
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: ******
@letsspeak
letsspeak / mysqlbackup.php
Created March 15, 2013 19:54
FuelPHP MySQL backup script
<?php
namespace Fuel\Tasks;
class MySQLBackup
{
public static function system_ex($cmd, $stdin = "")
{
$descriptorspec = array(
0 => array("pipe", "r"),
@letsspeak
letsspeak / mysql cli
Last active December 15, 2015 01:49
mysql creating fuelphp user APPLICATION_NAME is your application name
mysql> select * INTO OUTFILE 'dump.txt' from テーブル名;
mysql> LOAD DATA INFILE 'dump.txt' INTO TABLE テーブル名;
@letsspeak
letsspeak / 005_create_users.php
Created March 23, 2013 20:31
fuel-opauth controller using fixed-opauth package https://github.com/letsspeak/fuel-opauth
<?php
namespace Fuel\Migrations;
class Create_users
{
public function up()
{
\DBUtil::create_table('users', array(
'id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true),
@letsspeak
letsspeak / installing_cpanm_to_centos
Created March 29, 2013 15:25
installing cpanm to CentOS 6.3
$ cd /usr/bin/
$ sudo curl -LOk http://xrl.us/cpanm
$ sudo chmod +x cpanm
$ sudo cpanm local::lib
-> FAIL Installing ExtUtils::MakeMaker failed. See /root/.cpanm/build.log for details.
-> FAIL Bailing out the installation for App-cpanminus-1.5018. Retry with --prompt or --force.
$ sudo yum install perl-devel
$ sudo yum groupinstall "Development Tools"
$ sudo yum install pkgconfig glib2-devel gettext libxml2-devel pango-devel cairo-devel
$ cd /usr/bin/
$ sudo curl -LOk http://xrl.us/cpanm
$ sudo chmod +x cpanm
$ sudo cpanm local::lib
-> FAIL Installing ExtUtils::MakeMaker failed. See /root/.cpanm/build.log for details.
@letsspeak
letsspeak / centos_cpu_usage_one_liner.sh
Last active December 15, 2015 14:18
centos cpu usage one liner
# cpu usage (decimal)
cat /proc/loadavg | cut -d ' ' -f 1
# cpu usage (integral)
cat /proc/loadavg | cut -d ' ' -f 1 | cut -d '.' -f 1
# cpu usage (integral * 100)
cpu=`cat /proc/loadavg | cut -d ' ' -f 1`;echo $cpu*100 | bc | cut -d '.' -f 1
# send your cpu usage (integral) to GrowthForecast every 5 minutes via crontab
@letsspeak
letsspeak / centos_memory_usage_one_liner
Last active December 15, 2015 14:29
centos memory usage one liner
// memory usage percent (integral)
free | awk 'NR==2' | awk '{print int($3/$2*100)}'
// actual memory usage (integral)
// http://open-groove.net/linux-command/free/
free | awk 'NR==2' | awk '{print int(($3-($6+$7))/$2*100)}'
// swap memory usage percent (integral)
free | awk 'NR==4' | awk '{print int($3/$2*100)}'