Skip to content

Instantly share code, notes, and snippets.

@lalawue
lalawue / gist:430102f68327fe302964
Created March 7, 2015 16:38
Simple wrapper for VFL
// formula as 'width == width'
static NSLayoutConstraint*
_lcItemRel(UIView *v1, NSString *formula, UIView *v2, float ratio, float constant) {
static NSDictionary *attrValueForName = nil;
static dispatch_once_t attrOnceToken;
dispatch_once(&attrOnceToken, ^{
attrValueForName =
@{
@"left": @(NSLayoutAttributeLeft),
@"right": @(NSLayoutAttributeRight),
@lalawue
lalawue / gist:4ef9fbb13034c774722d
Created January 28, 2015 15:52
Read .wav audio file format and save the raw data
/*
* Copyright (c) 2015 lalawue
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the MIT license. See LICENSE for details.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@lalawue
lalawue / gist:3c9a210d9816767050b9
Created January 28, 2015 15:51
Read .aiff audio file format and save the raw data
/*
* Copyright (c) 2015 lalawue
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the MIT license. See LICENSE for details.
*/
#include <stdio.h>
#include <string>
#include <vector>
@lalawue
lalawue / gist:8303150
Created January 7, 2014 17:37
quickly locate C/C++/ObjC function in current buffer
;; for Xcode pragma mark, and C/C++ functions
(require 'anything)
(require 'anything-config)
(defvar anything-c-source-objc-headline
'((name . "Objective-C Headline")
(headline "^[-+@]\\|^#pragma mark")
))
(defvar anything-c-source-c-headline
@lalawue
lalawue / gist:8303105
Last active January 2, 2016 12:28
jump between C/C++/ObjC source and header file in Emacs
;; jump between source and header file
(defun c-base-mode-in-header-file ()
(let* ((filename (buffer-file-name))
(extension (car (last (split-string filename "\\.")))))
(string= "h" extension)))
(defun c-base-mode-file-jump-to-extension (extension)
(let* ((filename (buffer-file-name))
(file-components (append (butlast (split-string filename
"\\."))