Skip to content

Instantly share code, notes, and snippets.

Daniel, Dao Quang Minh dqminh

Block or report user

Report or block dqminh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View mongodb-restart.sh
#!/bin/bash
#replace /var/state and /var/state/mongodb with your proper path
sudo rm /var/state/mongodb/mongod.lock
sudo -u mongodb mongod --repair --dbpath=/var/state/mongodb
sudo /etc/rc.d/mongodb restart
@dqminh
dqminh / gist:964135
Created May 10, 2011
fetch_image.js
View gist:964135
var janitor = new Image(),
info = {},
test = $("#test"),
images = [];
$.get("somewhere_that_fetch_the_page").complete(function (data) {
var tmpImages = $(data.responseText).find("img");
tmpImages.each(function (key, img) {
var src = (img.getAttribute ? img.getAttribute("src") : false) || img.src;
@dqminh
dqminh / jqtfilter.py
Created May 25, 2011
JS template filter for webassets
View jqtfilter.py
"""
Webasset filter to combine JQuery Templates files into javascript-safe strings,
and put them into a namespace
"""
import os
from webassets.filter import Filter
class JqtFilter(Filter):
name = 'jqt'
@dqminh
dqminh / gist:1029041
Created Jun 16, 2011
mongodb-restart
View gist:1029041
#!/bin/bash
mongo_path=/var/lib/mongodb
sudo rm $mongo_path/mongod.lock
sudo -u mongodb mongod --repair --dbpath=$mongo_path
sudo /etc/init.d/mongodb restart
@dqminh
dqminh / wordwrap.py
Created Jun 28, 2011
basic word wrap
View wordwrap.py
def word_wrap(input, width):
input = input.strip()
if not input:
return ""
if len(input) < width:
return input
i = input.find(" ", width)
if i < 0:
return input[:width] + "\n" + word_wrap(input[width:], width)
View show_and_tell.rb
#!/usr/bin/env ruby
def get_time(format="%H:%M")
Time.now.strftime("%H:%M")
end
case get_time
when "09:00"
`say you should finish your breakfast in 10 minutes`
when "11:55"
@dqminh
dqminh / christmas.tree
Created Dec 5, 2011
We want this tree
View christmas.tree
$
:$$
seeee$$$Neeee
R$$$F$$$$F
$$$$$$
@$$P*$$B
z$#" $#$b
" d 'N "
@" ?r
xF . "N
@dqminh
dqminh / applause_formatter.rb
Last active Dec 18, 2015
rspec formatter that applause you when your tests pass
View applause_formatter.rb
require "rspec/core/formatters/progress_formatter"
class ApplauseFormatter < RSpec::Core::Formatters::ProgressFormatter
def initialize(output)
super(output)
unless File.exists? "/tmp/applause.mp3"
p "Downloading applause for awesomeness"
system "wget http://www.soundjay.com/human/applause-1.mp3 -O /tmp/applause.mp3"
end
end
View reset docker
pkill docker
iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0
docker -d
@dqminh
dqminh / access.log
Created Sep 3, 2013
docker private registry + nginx basic auth
View access.log
10.143.7.175 - - [02/Sep/2013:04:08:22 +0000] "GET /v1/_ping HTTP/1.1" 200 4 "-" "Go 1.1 package http" "-"
10.143.7.175 - - [02/Sep/2013:04:08:32 +0000] "POST /v1/users/ HTTP/1.1" 201 14 "-" "Go 1.1 package http" "-"
10.143.7.175 - - [02/Sep/2013:04:08:32 +0000] "GET /v1/_ping HTTP/1.1" 200 4 "-" "Go 1.1 package http" "-"
10.143.7.175 - docker [02/Sep/2013:04:08:32 +0000] "PUT /v1/repositories/test/essential/ HTTP/1.1" 200 2 "-" "go/go1.1.1 kernel/3.8.0-29-generic" "-"
10.143.7.175 - - [02/Sep/2013:04:08:32 +0000] "GET /v1/images/8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c/json HTTP/1.1" 401 194 "-" "go/go1.1.1 kernel/3.8.0-29-generic" "-"
10.143.7.175 - - [02/Sep/2013:04:08:32 +0000] "PUT /v1/images/8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c/json HTTP/1.1" 401 194 "-" "go/go1.1.1 kernel/3.8.0-29-generic" "-"
You can’t perform that action at this time.