Skip to content

Instantly share code, notes, and snippets.

View yusuke024's full-sized avatar

Yusuke Onishi yusuke024

  • Google
  • Tokyo, Japan
View GitHub Profile
@yusuke024
yusuke024 / Useful Mac Terminal Commands
Last active December 18, 2015 11:19
A terminal command to rebuild "Open With" index in OS X. If you have duplicated entries in the "Open With", this is the command for you.
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
# Git clean repo and remove untracked files and directories.
git clean -fxd
# Count number of commits from <commit/branch> to <commit/branch>
git log --oneline <start_but_excluded_commit/branch>..<end_included_commit/branch> | wc
# Download a file
curl -O http://example.com/file.txt
# Download a file and follow any redirection that may occurs
curl -LO http://example.com/file.txt
# Download a file to different name
curl -o myfile.txt http://example.com/file.txt
# or
curl http://example.com/file.txt > myfile.txt
@yusuke024
yusuke024 / gist:9212323
Created February 25, 2014 16:25
Install Node.js, the hard way
git clone git@github.com:joyent/node.git
cd node
./configure
make
make install
@yusuke024
yusuke024 / gist:9212591
Created February 25, 2014 16:37
Install NPM
curl https://npmjs.org/install.sh | sh
@yusuke024
yusuke024 / gist:2769da7b9570b07ae8a8
Last active August 29, 2015 14:00
Prevent table section header views from sticking at the top of the table view
// Implement this in the UITableView's subclass
// Please note that you have to return an instance of UITableViewHeaderFooterView's subclass in tableView:viewForHeaderInSection:
//
- (void)layoutSubviews {
[super layoutSubviews];
NSArray *visibleRows = [self indexPathsForVisibleRows];
NSMutableIndexSet *sections = [[NSMutableIndexSet alloc] init];
for (NSIndexPath *indexPath in visibleRows) {
[sections addIndex:indexPath.section];
@yusuke024
yusuke024 / hacker-news.sh
Last active August 29, 2015 14:07
Get Hacker News feed in Shell
#!/usr/bin/env sh
curl https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty | grep -o "[1-9][0-9]*" | xargs -I {} curl https://hacker-news.firebaseio.com/v0/item/{}.json?print=pretty
@yusuke024
yusuke024 / gist:38333a1d68e8f1155ad5
Created December 12, 2014 11:30
Clean Slack Files
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
@yusuke024
yusuke024 / server.go
Last active August 29, 2015 14:15
Go Web Socket implementation
package main
import (
"bufio"
"flag"
"fmt"
"io"
"log"
"net/http"
"os"
@yusuke024
yusuke024 / ticker.go
Created February 20, 2015 15:28
Ticker in Go
package main
import (
"flag"
"io"
"log"
"os"
"strconv"
"time"
)