Skip to content

Instantly share code, notes, and snippets.

char** vectorToCharPtrs(vector<const char*> args) {
int size = args.size;
char **argv = new char*[size];
for(int c = 0; c < size; ++c) {
argv[c] = args[c];
}
return argv;
}
<?php
function f() {
return array(1);
}
echo f()[0];
?>
# Contributor: Rainy <rainylau(at)gmail(dot)com>
# Contributor: Lee.MaRS <leemars at gmail dot com>
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>
# Maintainer: Brad Fanella <bradfanella@archlinux.us>
pkgname=ibus
pkgver=1.3.9
pkgrel=3
pkgdesc='Next Generation Input Bus for Linux.'
arch=('i686' 'x86_64')
@crabtw
crabtw / gist:1335971
Created November 3, 2011 07:22
fix ACTION command
diff --git a/Network/SimpleIRC/Messages.hs b/Network/SimpleIRC/Messages.hs
index ee729ef..33291d4 100644
--- a/Network/SimpleIRC/Messages.hs
+++ b/Network/SimpleIRC/Messages.hs
@@ -170,6 +170,6 @@ showCommand (MNick nick) = "NICK " `B.append` nick
showCommand (MNotice chan msg) = "NOTICE " `B.append` chan `B.append`
" :" `B.append` msg
showCommand (MAction chan msg) = showCommand $ MPrivmsg chan
- ("\x01 ACTION " `B.append` msg
- `B.append` "\x01")
--- sys/sys/ucontext.h.orig 2012-01-31 09:46:57.398803502 +0800
+++ sys/sys/ucontext.h 2012-01-31 09:47:09.813803548 +0800
@@ -79,7 +79,7 @@
int swapcontext(ucontext_t *, const ucontext_t *);
#if __BSD_VISIBLE
-size_t __getcontextx_size(void);
+__size_t __getcontextx_size(void);
int __fillcontextx(char *ctx);
#endif
# encoding: utf-8
require 'open-uri'
require 'pdf/reader'
io = open('http://www.nctu.edu.tw/campus/bulletin/Calendar/calendar2011.pdf')
reader = PDF::Reader.new(io)
sems = reader.pages.map do |page|
sem = page.text.scan(
/本學期自(\d+)年(\d+)月(\d+)日.+至(\d+)年(\d+)月(\d+)日/
./bindgen.rs:241:30: 241:50 error: unresolved name: CXType_FunctionProto
./bindgen.rs:241 if def_ty.kind == CXType_FunctionProto ||
^~~~~~~~~~~~~~~~~~~~
./bindgen.rs:242:30: 242:52 error: unresolved name: CXType_FunctionNoProto
./bindgen.rs:242 def_ty.kind == CXType_FunctionNoProto {
^~~~~~~~~~~~~~~~~~~~~~
./bindgen.rs:311:18: 311:31 error: unresolved name: CXType_Record
./bindgen.rs:311 if ty.kind == CXType_Record || ty.kind == CXType_Enum {
^~~~~~~~~~~~~
./bindgen.rs:311:46: 311:57 error: unresolved name: CXType_Enum
use std;
fn main() {
let j = std::json::from_str("[]");
io::println(#fmt["%?", j]);
}
@crabtw
crabtw / gist:4012547
Created November 4, 2012 16:43
ISO/IEC 9899:2011 6.5.8 - 5
When two pointers are compared, the result depends on the relative locations in the
address space of the objects pointed to. If two pointers to object types both point to the
same object, or both point one past the last element of the same array object, they
compare equal. If the objects pointed to are members of the same aggregate object,
pointers to structure members declared later compare greater than pointers to members
declared earlier in the structure, and pointers to array elements with larger subscript
values compare greater than pointers to elements of the same array with lower subscript
values. All pointers to members of the same union object compare equal. If the
expression P points to an element of an array object and the expression Q points to the
last element of the same array object, the pointer expression Q+1 compares greater than
float temp_decode(int16_t temp) {
int16_t hi = temp & 0xff00;
int16_t lo = temp & 0x00ff;
return (hi + lo) / 256.0;
}