Skip to content

Instantly share code, notes, and snippets.

View david50407's full-sized avatar

Davy david50407

View GitHub Profile
int main() { return 0; }
template <class T>
struct Interface
{
public:
// static T testing() {};
private:
static T (*__testing_checker)();
};
@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
@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
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 / 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
| | |
@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)
class Foo
@value = 0
def initialize(v = 0, v2 = 10)
@value = v
@value2 = 10
end
def value
@value
end
@david50407
david50407 / c_wrapper.cr
Last active November 12, 2015 20:16 — forked from jhass/lib_c.cr
Platform indepedent standard library for Crystal
ifdef linux
require "./linux_c_wrapper"
elsif windows
require "./windows_c_wrapper"
end
module CWrapper
ifdef linux
IMPL = OS::Linux::CWrapper
elsif windows
ifdef windows
# already required "./winapi/kernel32.cr" in prelude
else
require "./dl/lib_dl.cr"
end
# This is a frontend wrapper,
# using LibDL or WinApi as backend.
module DL
ifdef windows
import React from 'react'
import { Row, Col } from 'react-flexbox-grid'
import AppBar from 'material-ui/lib/app-bar'
import IconButton from 'material-ui/lib/icon-button'
import NavigationArrowBack from 'material-ui/lib/svg-icons/navigation/arrow-back'
import LoginForm from './components/LoginForm'
export default React.createClass({
contextTypes: {
router: React.PropTypes.object.isRequired,