Skip to content

Instantly share code, notes, and snippets.

@Psli
Psli / clean-docker-for-mac.sh
Created September 2, 2018 17:14 — forked from MrTrustor/clean-docker-for-mac.sh
This script cleans the Docker.qcow2 file that takes a lot of disk space with Docker For Mac. You can specify some Docker images that you would like to keep.
#!/bin/bash
# Copyright 2017 Théo Chamley
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in the Software
# without restriction, including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
# to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
@Psli
Psli / .vimrc
Created December 13, 2013 16:48
set guifont=Monaco:h10 " 字体 && 字号
set tabstop=4 " 设置tab键的宽度
set shiftwidth=4 " 换行时行间交错使用4个空格
set autoindent " 自动对齐
set backspace=2 " 设置退格键可用
set cindent shiftwidth=4 " 自动缩进4空格
set smartindent " 智能自动缩进
set ai! " 设置自动缩进
set nu! " 显示行号
set ruler " 右下角显示光标位置的状态行
@Psli
Psli / Macros.h
Created June 15, 2013 01:01 — forked from numo16/Macros.h
#define ApplicationDelegate ((AppDelegate *)[[UIApplication sharedApplication] delegate])
#define UserDefaults [NSUserDefaults standardUserDefaults]
#define NotificationCenter [NSNotificationCenter defaultCenter]
#define SharedApplication [UIApplication sharedApplication]
#define Bundle [NSBundle mainBundle]
#define MainScreen [UIScreen mainScreen]
#define ShowNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = YES
#define HideNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = NO
#define NetworkActivityIndicatorVisible(x) [UIApplication sharedApplication].networkActivityIndicatorVisible = x
#define NavBar self.navigationController.navigationBar

Ubuntu 12.10 setup (rbenv/rvm, janus, postgres)

Basic pre-requisites

  • Some utilities:
sudo apt-get install vim tmux git
  • Copy/paste from the command line:
@Psli
Psli / insertString.m
Created December 15, 2012 12:29 — forked from nacho4d/insertString.m
insert a string using UIKeyInput methods in UITextView in iOS5
- (void)insertString:(NSString *)inputKey
{
// Insert text (doing delegate calls appropiately)
NSRange changeRange = target.selectedRange;
if (!target.delegate || ([target.delegate respondsToSelector:@selector(textView:shouldChangeTextInRange:replacementText:)] &&
[target.delegate textView:target shouldChangeTextInRange:changeRange replacementText:inputKey])) {
// MarkedText could happen in multi-stage input languages
// In iOS5 several methods of UITextInput and UIKeyInput are badly implemented in UITextView
// setMarkedText:selectedRange: method seems to delete current markedText.
// Unmarking the text before inserting it is better than nothing.
@Psli
Psli / gist:4277126
Created December 13, 2012 15:27 — forked from qchenqizhi/gist:4029296
NSString has emoji
// Reference:
// https://github.com/iamcal/php-emoji
// http://de.wikipedia.org/wiki/Unicode-Block_Kombinierende_diakritische_Zeichen_f%C3%BCr_Symbole
- (BOOL)hasEmoji
{
__block BOOL emoji = NO;
[self enumerateSubstringsInRange:NSMakeRange(0, self.length)
options:NSStringEnumerationByComposedCharacterSequences
usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
// UIImage+Alpha.h
// Created by Trevor Harmon on 9/20/09.
// Free for personal or commercial use, with or without modification.
// No warranty is expressed or implied.
// Helper methods for adding an alpha layer to an image
@interface UIImage (Alpha)
- (BOOL)hasAlpha;
- (UIImage *)imageWithAlpha;
- (UIImage *)transparentBorderImage:(NSUInteger)borderSize;
@Psli
Psli / README.md
Created May 22, 2012 18:13 — forked from chrisbloom7/README.md
A cheap knock off of the default validates_length_of validator, but checks the filesize of a Carrierwave attachment

Note that this validation runs both after the file is uploaded and after CarrierWave has processed the image. If your base uploader includes a filter to resize the image then the validation will be run against the resized image, not the original one that was uploaded. If this causes a problem for you, then you should avoid using a resizing filter on the base uploader and put any specific size requirements in a version instead.

So instead of this:

require 'carrierwave/processing/mini_magick'

@Psli
Psli / AutoLocalize.h
Created February 12, 2012 20:52 — forked from sma/AutoLocalize.h
Automatically localize all strings in XIB files settable by IB
//
// AutoLocalize.h
// AutoLocalize
//
// Created by Stefan Matthias Aust on 05.08.11.
// Copyright 2011 I.C.N.H. All rights reserved.
//
#import <UIKit/UIKit.h>
@Psli
Psli / Capistrano tasks for starting unicorn.rb
Created September 27, 2011 22:02 — forked from vvalgis/Capistrano tasks for starting unicorn.rb
Capistrano tasks for starting unicorn
set :rails_env, :production
set :unicorn_binary, "/usr/bin/unicorn"
set :unicorn_config, "#{current_path}/config/unicorn.rb"
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
namespace :deploy do
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && #{try_sudo} #{unicorn_binary} -c #{unicorn_config} -E #{rails_env} -D"
end
task :stop, :roles => :app, :except => { :no_release => true } do