Skip to content

Instantly share code, notes, and snippets.

Avatar

Masaya Suzuki draftcode

View GitHub Profile
View Test.java
class Test {
int var = 42;
void variableScope() {
switch (var) {
case 42:
int a = 1;
case 43:
// a is visible.
a = 2;
}
View two_bucket_shortest_path.rb
class TwoBucketShortestPathCalculator
def initialize(cap_a, cap_b)
@cap_a = cap_a
@cap_b = cap_b
end
def answer
@answer ||= calculate
end
View test.c
int printf();
int main() {
int (*fp)() = printf;
fp = ******fp;
(*********fp)("asdf\n");
}
View Makefile
all_fullscreen: all_fullscreen.cc
${CXX} -std=c++11 -lX11 -lXinerama -lXrandr -o $@ $^
View indicate_last.py
# -*- coding: utf-8 -*-
from __future__ import division, absolute_import, print_function, unicode_literals
def indicate_last(gen):
saved_e = None
prev_value = next(gen)
value = None
while True:
if saved_e is not None:
raise saved_e
View regexp.c
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
typedef struct _node {
char c;
struct _node *tr;
struct _node *next;
} node;
View shape.c
#include <stdio.h>
#include <stdlib.h>
#pragma pack(8)
struct shape_vtbl;
typedef struct {
double x, y;
struct shape_vtbl *shape_vtbl;
} SHAPE;
View test.awk
#!/usr/bin/gawk -f
# $ echo 'a[1] = b[1]' | ./test.awk pattern='.\\[[[:digit:]]\\]'
# a[1]
# b[1]
{
s = $0
while (match(s, pattern)) {
print substr(s, RSTART, RLENGTH)
s = substr(s, RSTART+RLENGTH)
}
View Makefile
xrrtest: xrrtest.cpp
${CXX} -lX11 -lXinerama -lXrandr -o xrrtest xrrtest.cpp
View Rakefile
require "rake/clean"
$OUTPUT = File.basename(File.expand_path("..", __FILE__))
$OUTPUTDIR = "out"
$TEX = "platex"
$TEXFLAGS = ""
$DVIPDF = "dvipdfmx"
$DVIPDFFLAGS = ""
$BIBTEX = "pbibtex"
You can’t perform that action at this time.