Skip to content

Instantly share code, notes, and snippets.

View GeneralD's full-sized avatar
💭
Alcohol makes better code 🥃

YUMENOSUKE GeneralD

💭
Alcohol makes better code 🥃
View GitHub Profile
# usage sample: echo Let\'s ${RED}color${CLEAR} text!
CLEAR='\033[0m'
BLACK='\033[0;30m'
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
CYAN='\033[0;36m'
constructor(private iab: InAppBrowser) {}
openUrl(url: string, externalBrowser: boolean = false) {
const target = externalBrowser ? '_system' : '_blank';
this.iab.create(url, target, TopicDetailPage.options);
}
# Java use IPv4 for jenkins
alias jenkins='env _JAVA_OPTIONS="-Djava.net.preferIPv4Stack=true" jenkins'
# zmv
autoload -Uz zmv
alias zmv='noglob zmv -W'
@GeneralD
GeneralD / parent-directory.zsh
Last active August 26, 2018 14:18
[parent-directory.zsh] #Shell #Ruby
# cd to parent directory of the file (even if it is symbolic link)
function pd() {
local dir=`realpath ${1:-.}`
cd $dir(:A:h)
}
# alias -g ...=../../, ....=../../../, .....=../../../../, ......
`ruby -e "(2..20).each{|i| puts 'alias -g .'+'.'*i+'='+'../'*i}"`
true
#!/usr/bin/env zsh
(){
local plistfile="$HOME/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist"
local i=0
while [[ $i != "false" ]]; do
[[ `/usr/libexec/PlistBuddy -c "Print :LSHandlers:$i" $plistfile 2>/dev/null` ]] || break
ext=`/usr/libexec/PlistBuddy -c "Print :LSHandlers:$i:LSHandlerContentTag" $plistfile 2>/dev/null`
zle-pbcopy-buffer(){ echo -n ${(z)BUFFER} | pbcopy }
zle -N zle-pbcopy-buffer
@GeneralD
GeneralD / .zshrc
Last active September 6, 2018 12:13
必要なファイルのみzcompileする ref: https://qiita.com/GeneralD/items/73e31ab8cf9aa01e480f
() { # zcompile if needed
local src
for src in $@; do
([[ ! -e $src.zwc ]] || [[ $src:A -nt $src.zwc ]]) && zcompile $src
done
} ~/.zshenv ~/.zshrc ~/.zprofile ~/.zlogin ~/.zlogout
using System;
using System.Collections.Generic;
using System.Linq;
namespace Hanoi {
class HanoiTower {
static void Main(string[] args) {
int height;
if (args.Length == 0 || !int.TryParse(args[0], out height)) height = 3;
var count = 0;
require 'mechanize'
require 'json'
# your my softbank login id and password
phone = "***********"
password = "********"
agent = Mechanize.new
agent.user_agent_alias = 'iPhone'
agent.follow_meta_refresh = true