Skip to content

Instantly share code, notes, and snippets.

@xjlu
xjlu / gist:9832b2773edd2cf10e3f
Created July 7, 2014 20:20
How to reset Safari's address bar search engine?
I accidently installed some adware from Genieo, and I tried to remove all files but still the safari's address bar search is still defaulted to genieo.com. Google pointed me to this apple support page: https://discussions.apple.com/thread/6021681, which is mainly for people who are not tech savvy.
Here is how I fixed it, and it's mainly for people who are comfortable with command line stuff. The culprit is that geneio installed a /etc/launchd.conf, and override some environment variable. Here is a link from thesafemac.com: http://www.thesafemac.com/arg-genieo/.
Note that on that page, it's HIGHLY recommended to remove/change the launchd.conf file before changing other files, otherwise the computer may freeze or fail to start due to missing files.
A quick fix is to sudo open the /etc/launchd.conf (should be a oneline file), then remove the line referring to /usr/lib/libimckit.dylib or simplify remove this file. A restart should fix the safari search bar issue. You may also want to remove those files listed
@xjlu
xjlu / .gemrc
Created February 15, 2014 08:57 — forked from jch/.gemrc
# http://docs.rubygems.org/read/chapter/11
---
gem: --no-ri --no-rdoc
benchmark: false
verbose: true
update_sources: true
sources:
- http://gems.rubyforge.org/
- http://rubygems.org/
backtrace: true
@xjlu
xjlu / gist:8905065
Created February 9, 2014 20:00
How to get a char of a Ruby string?
# Just came across String#chars method, which returns an enumerable.
# It's implementation is much simpler than String#split.
# A simple benchmark shows that String#chars is much faster than String#split.
require 'benchmark/ips'
Benchmark.ips do |r|
s = "The Snow Queen"
r.report('chars') do
@xjlu
xjlu / gist:6224663
Created August 13, 2013 19:17
nginx.conf for nginx 1.4.2
user www-data;
worker_processes 2;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@xjlu
xjlu / gist:4541736
Created January 15, 2013 20:26
show your current branch name in shell prompt
# show git branch name in the prommpt
function parse_git_branch {
#git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
git rev-parse --abbrev-ref HEAD 2> /dev/null | sed -e 's/\(.*\)/(\1)/'
}
function proml {
local BLUE="\[\033[0;34m\]"
local RED="\[\033[0;31m\]"
@xjlu
xjlu / gist:1678645
Created January 25, 2012 20:51
setup emcee nginx config for self-signed certification
# how to generate self-signed ssl certs.
# http://dracoblue.net/dev/https-nginx-with-self-signed-ssl-certificate/188/
# A sample server configuration for nginx's emcee.conf
server {
listen 443; # for Linux
ssl on;
ssl_certificate /etc/nginx/server.crt;
ssl_certificate_key /etc/nginx/server.key;
client_max_body_size 4G;