Skip to content

Instantly share code, notes, and snippets.

View david50407's full-sized avatar

Davy david50407

View GitHub Profile
class Foo
@value = 0
def initialize(v = 0, v2 = 10)
@value = v
@value2 = 10
end
def value
@value
end
@david50407
david50407 / hanoi.cpp
Last active November 10, 2015 10:14
Benchmark by doing Tower of Hanoi problem in recursive way.n = 20Pseudo code from Wikipedia: https://zh.wikipedia.org/wiki/汉诺塔
/* Compile with: clang++ -Ofast */
/* Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4) */
/* 5.70s, 1.0Mb */
#include <iostream>
#include <cstdio>
using namespace std;
void hannoi (int n, char from, char buffer, char to)
{
if (n == 1)
@david50407
david50407 / new_gist_file_0
Created November 9, 2015 15:42
Ruby 常用 pack
If the count is an asterisk (“*”), all remaining array elements will be converted.
C | Integer | Array |
Type | Directive | Element | Meaning
---------------------------------------------------------------------------------------
char | c | Integer | 8-bit signed
short | s | Integer | 16-bit signed, native endian
int | l | Integer | 32-bit signed, native endian
long long | q | Integer | 64-bit signed, native endian
| | |
Integer | Array |
Directive | Element | Meaning
---------------------------------------------------------------------------
C | Integer | 8-bit unsigned (unsigned char)
S | Integer | 16-bit unsigned, native endian (uint16_t)
L | Integer | 32-bit unsigned, native endian (uint32_t)
Q | Integer | 64-bit unsigned, native endian (uint64_t)
| |
c | Integer | 8-bit signed (signed char)
s | Integer | 16-bit signed, native endian (int16_t)
@david50407
david50407 / 0_reuse_code.js
Created November 2, 2015 18:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@david50407
david50407 / create-startssl-cert-bundle.sh
Created July 25, 2015 08:55 — forked from evansd/create-startssl-cert-bundle.sh
Read a SSL certificate issued by StartSSL and bundle intermediate certificates into it so it works everywhere
#!/bin/bash
set -eo pipefail
cert_file="$1"
if [ -z "$cert_file" ]; then
echo "Usage: create-startssl-cert-bundle CERTIFICATE_FILE" >&2
echo >&2
echo "Bundles StartSSL's intermediate certs and writes combined certificate to stdout" >&2
exit 1
int main() { return 0; }
template <class T>
struct Interface
{
public:
// static T testing() {};
private:
static T (*__testing_checker)();
};

整理自 KKBOX 討論區的「KKBOX 授權擁有的動漫卡通音樂 集中帖」的第一頁(討論串樓主整理的)

需注意後面零星的歌單並沒有整理到這裡

這個 gist 是整理到 ACG Music (Taiwan) 前整理用 temp。

「鋼之鍊金術師」

《劇場版 主題曲》Link-L'Arc-en-Ciel(彩虹樂團)

require 'matrix'
require 'complex'
Matrix[[2, 1], [-1, 2]].det
def det(row1, row2):
return row1[0] * row2[1] - row1[1] * row2[0]
l4d2 = [[1, 2], [3, 4]]
det(*l4d2)