Skip to content

Instantly share code, notes, and snippets.

View misdake's full-sized avatar

misdake misdake

  • Shanghai
  • 21:21 (UTC +08:00)
  • X @rSkip
View GitHub Profile
@misdake
misdake / main.rs
Created May 2, 2022 02:34
Rust Lifetime Annotation
fn select_u32<'a>(a: &'a u32, b: &'a u32, select_a: &'a bool) -> &'a u32 {
if *select_a { a } else { b }
}
const STR_A: &'static str = "A";
const STR_B: &'static str = "B";
fn select_str(s: &str) -> &str {
if s.is_empty() { STR_A } else { STR_B }
}
@misdake
misdake / gist:a32c91c11a1f422127797c605ca5ca53
Created June 13, 2021 10:52
Load custom levels for forknjoin
window.loadlevel({
name: "Help each other",
maxtime: 25,
goldtime: 17,
map: [
w, w, w, w, w, w, w, w, w,
w, w, w, w, w, w, w, w, w,
w, o, o, o, c, o, o, o, w,
w, o, w, w, U, w, w, w, w,
P, o, w, w, o, w, o, o, Z,
#If GetKeyState("CapsLock", "T") = 1
w::SendInput {Ctrl Down}{Shift Down}{Tab Down}
w up::SendInput {Ctrl Up}{Shift Up}{Tab Up}
r::SendInput {Ctrl Down}{Tab Down}
r up::SendInput {Ctrl Up}{Tab Up}
a::SendInput {Blind}{Home Down}
a up::SendInput {Blind}{Home Up}
g::SendInput {Blind}{End Down}
g up::SendInput {Blind}{End Up}
/*
* Simple script for running emcc on ARToolKit
* @author zz85 github.com/zz85
*/
var
exec = require('child_process').exec,
path = require('path'),
fs = require('fs'),
1 CppCon 2015: Bjarne Stroustrup “Writing Good C++14”
2 CppCon 2015: Herb Sutter "Writing Good C++14... By Default"
3 CppCon 2015: Sean Parent "Better Code: Data Structures"
4 CppCon 2015: Chandler Carruth "Tuning C++: Benchmarks, and CPUs, and Compilers! Oh My!"
5 CppCon 2015: Eric Niebler "Ranges for the Standard Library"
6 CppCon 2015: Vittorio Romeo “Implementation of a component-based entity system in modern C++”
7 CppCon 2015: Joel Falcou PART 1 “Expression Templates - Past, Present, Future”
8 CppCon 2015: Scott Wardle “Memory and C++ debugging at Electronic Arts”
9 CppCon 2015: André Bergner “Faster Complex Numbers”
10 CppCon 2015: Louis Dionne “C++ Metaprogramming: A Paradigm Shift"
@misdake
misdake / JpegExif.java
Created August 4, 2016 12:08
read jpeg exif
//https://github.com/drewnoakes/metadata-extractor
public class JpegExif {
public static void main(String[] args) throws ImageProcessingException, IOException {
File file = new File("E:/org_3e1fa47a903c1ccb_1470295646000.jpg");
int w = 4;
int h = 3;
double rw = 1.0 * w / Math.hypot(w, h);
double rh = 1.0 * h / Math.hypot(w, h);
@misdake
misdake / enum.java
Last active May 5, 2016 10:42
触目惊心的enum get
public final static T get(int value) {
for (int i = 0; i < values().length; i++) {
if (values()[i].value == value) {
return values()[i];
}
}
return null;
}
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF8">
<meta name="description" content="URL selfhosting content">
<meta name="keywords" content="self hosting web pages by abusing the url">
<meta name="author" content="MJS 2016-02-25">
<script>
LZString=function(){function o(o,r){if(!t[o]){t[o]={};for(var n=0;n<o.length;n++)t[o][o.charAt(n)]=n}return t[o][r]}var r=String.fromCharCode,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",t={},i={compressToBase64:function(o){if(null==o)return"";var r=i._compress(o,6,function(o){return n.charAt(o)});switch(r.length%4){default:case 0:return r;case 1:return r+"===";case 2:return r+"==";case 3:return r+"="}},decompressFromBase64:function(r){return null==r?"":""==r?null:i._decompress(r.length,32,function(e){return o(n,r.charAt(e))})},compressToUTF16:function(o){return null==o?"":i._compress(o,15,function(o){return r(o+32)})+" "},decompress
@misdake
misdake / java_object_sizes.txt
Last active February 24, 2016 09:40
java object sizes on Oracle JRE.
64bit JVM 32bit JVM
16 8 new Object()
216 216 new char[100]
16 16 new Integer(1)
24 16 new Long(1)
24 16 new Double(1)
40 40 new ArrayList()
@misdake
misdake / volume
Last active December 25, 2015 10:22
find proper volume numbers
boolean[] r = new boolean[500];
Arrays.fill(r, false);
r[2] = r[3] = r[5] = true;
for (int i = 2; i != 100; i++) {
if(r[i]) {
r[i*2] = r[i*3] = r[i*5] = true;
System.out.println(i);
}
}