Skip to content

Instantly share code, notes, and snippets.

@holin
holin / brew_install_things.md
Last active January 13, 2017 02:17
Homebrew install

brew service

brew service list
brew services start|stop|restart
brew services cleanup

PostgreSQL

@holin
holin / match_and_replace.js
Created December 1, 2016 01:49
Match and replace
function replacer(match, offset, string){
console.log(arguments)
return ["x", match, "x"].join('');
};
var str = 'a1b2c3d';
var regex = /\d/ig;
var newString = str.replace(regex, replacer);
console.log(newString)
/* - - - - - - - - - - - - - - - - - - - - -
Title : Example Custom CSS : DinoMaster!
URL : http://wufoo.com
Last Updated : April 1, 2011
- - - - - - - - - - - - - - - - - - - - -
INSTRUCTIONS
@holin
holin / backup-site-database.sh
Created December 23, 2015 02:48
backup site
#!/bin/sh
RANDNUMBER=`shuf -i1-10000 -n1`
# echo "RANDNUMBER $RANDNUMBER"
cd /mnt/bak
# backup files
echo "backup files..."
cp -r /www/web/brch/public_html /root/bak/public_html_`date +"%Y-%m-%d"`_$RANDNUMBER
@holin
holin / mysql-backup-user
Created December 23, 2015 02:46
Create MySQL user to backup databases
CREATE USER 'dbbackup'@'localhost' IDENTIFIED BY 'backuppassword874';
GRANT SELECT ,
RELOAD ,
FILE ,
SUPER ,
LOCK TABLES ,
SHOW VIEW ON *.* TO 'dbbackup'@'localhost' IDENTIFIED BY 'backuppassword874' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
@holin
holin / brew-install-mysql
Created October 15, 2015 08:24 — forked from sandyxu/brew-install-mysql
brew install mysql & my.cnf & init database & start mysql & change root password & uninstall & show character & some solution s
1. brew安装mysql
$ brew install mysql
2. 创建或修改/usr/local/etc/my.cnf
https://gist.github.com/sandyxu/6317492
3. 初始化 init database
$ unset TMPDIR
$ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myCell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"myCell"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
cell.textLabel.text = self.justCourseNamesArray[indexPath.row];
create this file in your /root folder
$ fleetctl load swapon.service
$ fleetctl start swapon.service
This will create swap file on all nodes of your CoreOS cluster without prior setup.
See also http://cloudinit.readthedocs.org/en/latest/topics/examples.html#adjust-mount-points-mounted
@holin
holin / angularjs_filter_trustashtml
Created September 29, 2014 09:54
AngularJS with trustAsHtml and filter
// version info
// angular.version
// Object {full: "1.2.25", major: 1, minor: 2, dot: 25, codeName: "hypnotic-gesticulation"}
//filters:
.filter('html', function($sce) {
return function(text) {
return $sce.trustAsHtml(text);
};
@holin
holin / MapReduce
Created September 19, 2014 10:20
User count for each city
map = %Q{
function() {
if (this.mobile_city) {
emit(this.mobile_city, 1);
}
}
}
reduce = %Q{
function(key, values) {