Skip to content

Instantly share code, notes, and snippets.

<style type="text/css">
.backup_image {
width:100px;
height: 100px;
background-image: url(http://URL/TO/BACKUP/IMAGE);
background-repeat: no-repeat;
background-position: center center;
}
</style>
GRANT ALL ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE ON db_name.* TO 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'127.0.0.%' IDENTIFIED BY 'password' WITH GRANT OPTION;
GRANT REPLICATION SLAVE ON *.* TO repl@"192.168.1.%" IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
if (a == 1)
return 1;
else if (a == 2)
return 2;
else if (a == 3)
return 3;
--
-- Haskell 版本的分錢程式
--
divideInto :: (Integral a) => a -> a -> [a]
divideInto total n = divideAux total n []
where
divideAux total n xs
| n > 0 = divideAux (total-first) (n-1) (first:xs)
| otherwise = xs
where
<!-- Dynamically adjust an iframe’s height
via http://www.mattcutts.com/blog/iframe-height-scrollbar-example/ -->
<body onload="resizeFrame(document.getElementById('childframe'))">
<script type=”text/javascript”>
/* Firefox worked fine.
Internet Explorer shows scrollbar because of frameborder */
function resizeFrame(f) {
f.style.height = f.contentWindow.document.body.scrollHeight + “px”;
@wancw
wancw / radix_sleep_sort.rb
Created June 24, 2011 09:17
Mix of radix sort and sleep sort. (inspired by @fcamel)
#!/usr/bin/env ruby
#
# fcamel's implementation in Python: https://gist.github.com/1042867
#
def radix_sleep_sort(numbers)
max_length = numbers.map {|n| n.to_s.length }.max
return numbers if max_length.nil?
@wancw
wancw / LICENSE.txt
Created August 15, 2012 05:57 — forked from jed/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
#include <stdio.h>
typedef void (*func_ptr_t)(int x, ...);
void foo(int x) {
printf("foo(%d)\n", x);
}
void bar(int x, int y, int z) {
printf("foo(%d, %d, %d)\n", x, y, z);
@wancw
wancw / pr.md
Created March 28, 2013 02:11 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

import android.view.View;
import android.view.ViewGroup;
/**
* A {@link ViewGroup.OnHierarchyChangeListener hierarchy change listener} which recursively
* monitors an entire tree of views.
*/
public final class HierarchyTreeChangeListener implements ViewGroup.OnHierarchyChangeListener {
/**
* Wrap a regular {@link ViewGroup.OnHierarchyChangeListener hierarchy change listener} with one