Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Coding for food

bw2012

💭
Coding for food
View GitHub Profile
@bw2012
bw2012 / .gitconfig
Created Feb 9, 2017
Pretty git branch graphs
View .gitconfig
# http://stackoverflow.com/questions/1057564/pretty-git-branch-graphs
# vim ~/.gitconfig
[alias]
lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = !"git lg1"
@bw2012
bw2012 / list.cpp
Created Jul 11, 2018
lock free test
View list.cpp
#include <stdio.h>
#include <atomic>
template<typename V>
class LockFreeList {
struct Node {
V value;
std::shared_ptr<Node> next;
Node(const V& value) : value(value), next(nullptr) {}
};
View fuzzy_string_distance.cpp
// ==========================================================
template <typename T>
typename T::value_type levenshtein_distance(const T& src, const T& dst) {
const typename T::size_type m = src.size();
const typename T::size_type n = dst.size();
if (m == 0) {
return n;
}
@bw2012
bw2012 / devices.c
Last active Jan 30, 2019 — forked from courtneyfaulkner/devices.c
List OpenCL platforms and devices
View devices.c
#include <stdio.h>
#include <stdlib.h>
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif
int main() {
View Makefile
all:
gcc -shared -fPIC inspect.c -o inspect.so -ldl
View kvdb_example.cpp
#include "kvdb.h"
#include <cstring>
typedef struct TestStr {
int id = 0;
}TestStr;
int main() {
std::string fileName = "d://test_storage.dat";
@bw2012
bw2012 / http_download.cpp
Created Apr 6, 2019
C++ http download file
View http_download.cpp
#include <iostream>
#include <stdio.h>
#include <sys/socket.h>
//#include <stdlib.h>
#include <netinet/in.h>
#include <string.h>
#include <netdb.h>
#include <arpa/inet.h>
//#include <unistd.h>
@bw2012
bw2012 / gist:e7acfec738825b7e1683743d6fbfbce3
Created Apr 11, 2019
git squash branch to one commit
View gist:e7acfec738825b7e1683743d6fbfbce3
git checkout master
git merge --squash [branch]
git add .
git commit
@bw2012
bw2012 / gist:8132267969a8c4abbf99915a8d562c49
Created Feb 20, 2020
VirtualBox changing screen resolution of Mac OS guest
View gist:8132267969a8c4abbf99915a8d562c49
VBoxManage setextradata "High Sierra" VBoxInternal2/EfiGraphicsResolution 1920x1080
View .gitconfig
[alias]
lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = !"git lg1"