Skip to content

Instantly share code, notes, and snippets.

View akinsho's full-sized avatar

Akin akinsho

  • London
View GitHub Profile
@akinsho
akinsho / CMakeLists.txt
Created January 30, 2019 18:41 — forked from fracek/CMakeLists.txt
CMake and GTK+ 3
# Set the name and the supported language of the project
PROJECT(hello-world C)
# Set the minimum version of cmake required to build this project
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
# Use the package PkgConfig to detect GTK+ headers/library files
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0)
# Setup CMake to use GTK+, tell the compiler where to look for headers
@akinsho
akinsho / Order.js
Created September 14, 2018 15:36
Order List of comma separated strings
const input = [
"tom,swimming",
"john,running",
"sam,math",
"jane,swimming",
"john,math",
"jane,climbing",
"tom,climbing"
]
@akinsho
akinsho / mergeDeep.ts
Created September 1, 2018 10:29
Deep merge in TS
type Unknown = string | boolean | object | number
function isObject(item: Unknown) {
return item && typeof item === "object" && !Array.isArray(item)
}
const isArray = (elem: Unknown) => Array.isArray(elem)
export default function mergeDeep<T extends object>(target: T, source: T): T {
let output = Object.assign({}, target)
@akinsho
akinsho / pr.md
Created July 17, 2018 09:34 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@akinsho
akinsho / git-export
Created May 29, 2018 23:19 — forked from kristofferh/git-export
"Export" a git repository to zip file
git archive --format zip --output /full/path/to/zipfile.zip master
@akinsho
akinsho / gist:808ada19f29a6dbc8f32fb15171131ea
Created May 8, 2018 21:41 — forked from stuart11n/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@akinsho
akinsho / merge-deep.js
Created March 27, 2018 18:02 — forked from kylealwyn/merge-deep.js
recursively merge two javascript objects
/**
* Simple is object check.
* @param item
* @returns {boolean}
*/
function isObject(item) {
return (item && typeof item === 'object' && !Array.isArray(item));
}
/**
@akinsho
akinsho / gist:8b74031d04baee7a6794f2668a48bd43
Created January 12, 2018 12:32 — forked from paulallies/gist:0052fab554b14bbfa3ef
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
@akinsho
akinsho / emmet.vim
Created July 26, 2017 21:16
Tab completetion with emmet vim
" tab through emmet fields
function! s:move_to_next_emmet_area(direction)
" go to next item in a popup menu
if pumvisible()
if (a:direction == 0)
return "\<C-p>"
else
return "\<C-n>"
endif
endif
@akinsho
akinsho / requestAnimationFrame.js
Created June 13, 2017 12:51 — forked from jacob-beltran/requestAnimationFrame.js
React Performance: requestAnimationFrame Example
// How to ensure that our animation loop ends on component unount
componentDidMount() {
this.startLoop();
}
componentWillUnmount() {
this.stopLoop();
}