Skip to content

Instantly share code, notes, and snippets.

@PaulChana
PaulChana / sizeofcarray.c
Created June 6, 2017 11:23
Size of c array
(sizeof(a) / sizeof(*a))
@PaulChana
PaulChana / ShowHideCursor.c
Created June 6, 2017 10:56
Show / Hide the cursor on a console
void setConsoleCursorVisibility (const bool visible)
{
if (! visible)
std::cout << "\033[?25l" << std::flush;
else
std::cout << "\033[?25h" << std::flush;
}
@PaulChana
PaulChana / LLDB String Length
Created December 1, 2016 17:20
Set string length in LLDB
set set target.max-string-summary-length 10000
@PaulChana
PaulChana / DragAndDropTextField.h
Created October 17, 2016 11:07
NSTextField enabled for drag and drop from finder
#import <Cocoa/Cocoa.h>
@interface DragAndDropTextField : NSTextField
@end
@PaulChana
PaulChana / NSTaskAsyncOutput.mm
Created October 17, 2016 09:12
NSTask Async output to NSTaskView
NSMutableArray *arguments = [[NSMutableArray alloc] init];
[arguments addObject:[[NSBundle mainBundle] pathForResource:@"MyScript" ofType:@"py"]];
[arguments addObject:@"--verbose"]; // Any arguments you want here...
NSTask* task = [[NSTask alloc] init];
task.launchPath = @"/usr/bin/python";
task.arguments = arguments;
NSMutableDictionary *defaultEnv = [[NSMutableDictionary alloc] initWithDictionary:[[NSProcessInfo processInfo] environment]];
[defaultEnv setObject:@"YES" forKey:@"NSUnbufferedIO"] ;
@PaulChana
PaulChana / ShowExtended.sh
Created October 6, 2016 09:55
Show extended attributes in terminal
ls -al@
@PaulChana
PaulChana / UniformDistribution.cpp
Last active March 12, 2018 11:49
C++ uniform distribution random numbers
#include <random>
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(1, 6);
const int rnd = dis(gen);
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_real_distribution<> dis(-1.f, 1.f);
@PaulChana
PaulChana / cmdline.txt
Last active September 6, 2016 07:29
Force raspberry pi to break its startup sequence
rw init=/bin/bash
@PaulChana
PaulChana / LLDB Print Array
Last active February 11, 2024 12:58
View array in LLDB
p *(int(*)[10])ptr
@PaulChana
PaulChana / VSArray
Created May 12, 2016 13:19
View Array in Visual studi
If you have a buffer named, say, buf, write this in the watch window:
buf, 200
And VS will show you the first 200 elements of the array.