Skip to content

Instantly share code, notes, and snippets.

Ex 1.1: Experiment with “hello world” program

int main(void) {
    printf("hello, world\n");
    return 0;
}
@chrisbodhi
chrisbodhi / CLI Alias
Last active August 22, 2019 12:53
Alias for my command line
# Located in ~/.zshrc
ZSH_THEME="muse"
alias desk="cd ~/Desktop"
alias code="cd ~/Code"
alias git="hub"
alias ga="git add"
alias gc="git commit"
alias gpom="git push origin master"
[user]
email = TODO
name = chrisbodhi
[core]
excludesfile = /Users/TODO/.gitignore_global
pager = diff-so-fancy | less --tabs=4 -RFX
[commit]
template = /Users/TODO/.gitmessage
[color]
ui = true
*~
.DS_Store
.vscode/
node_modules/
@chrisbodhi
chrisbodhi / settings.json
Last active January 29, 2019 20:46
VS Code settings file
{
"css.validate": false,
"editor.cursorBlinking": "solid",
"editor.fontFamily": "Go Mono, Menlo, Monaco, 'Courier New', monospace",
"editor.fontSize": 13,
"editor.minimap.enabled": false,
"editor.rulers": [
80
],
"editor.tabSize": 4,
@chrisbodhi
chrisbodhi / sed.sh
Created September 4, 2018 21:21
Replace the string "name" with "displayName" using sed
➜ sed -i "" -e "s/name/displayName/" fileName
@chrisbodhi
chrisbodhi / double-index.html
Last active February 2, 2018 21:03
Display desktop and mobile views, side-by-side
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Side-by-side</title>
<style>
@chrisbodhi
chrisbodhi / closureTest.js
Created August 1, 2015 16:08
What will the value of `i` be in the alert box when `first()` and `tenth()` are called?
function makeGalaxy(size) {
var stars = [];
for (var i = 0; i < size; i++) {
stars.push(function(){alert("This is star #" + i);});
}
return stars;
};
var galaxy = makeGalaxy(20);
@chrisbodhi
chrisbodhi / countOfSmaller.js
Created August 3, 2017 18:26
Returns an array of counts of elements smaller than the current element of an array
/**
* @param {number[]} nums
* @return {number[]}
Given nums = [5, 2, 6, 1]
To the right of 5 there are 2 smaller elements (2 and 1).
To the right of 2 there is only 1 smaller element (1).
To the right of 6 there is 1 smaller element (1).
To the right of 1 there is 0 smaller element.
@chrisbodhi
chrisbodhi / sumFromString.js
Last active July 27, 2017 16:29
Given a string containing alphanumeric characters, calculate sum of all numbers present in the string.
function sumFromString(str) {
let sum = 0;
let acc = '0';
for (var i = 0; i < str.length; i +=1) {
if (parseInt(str[i])) {
acc += str[i]
if (i === (str.length - 1)) {
sum += parseInt(acc);
}
} else {