Skip to content

Instantly share code, notes, and snippets.

@christianwish
christianwish / delete-local-branches.sh
Created January 31, 2019 09:28
delete all local git branches but not master
git branch | grep -v "master" | xargs git branch -D
@christianwish
christianwish / index.php
Last active January 26, 2019 16:02
This happens when a JS developer works with PHP
<?php
include('./template-engine.php');
// Use functions to add dynamic data in Components
function HtmlBasic ($headInner, $children) {
return html(
head($headInner),
body($children)
);
};
@christianwish
christianwish / F.hs
Last active January 10, 2019 14:56
Functor hs
module F where
data Mappable a = A a | B a deriving (Show, Eq)
instance Functor Mappable where
fmap f (A x) = A (f x)
fmap f (B x) = B (f x)
-- Usage
a = A 3
@christianwish
christianwish / my.code-snippets
Created October 12, 2018 10:05
VSCODE snippets for JavaScript
{
// Place your snippets for javascriptreact here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
"React Dump": {
"prefix": "DUMP",
"body": [
"import React from 'react';",
"import PropTypes from 'prop-types';",
@christianwish
christianwish / clock.py
Created September 28, 2018 10:42
sublime text 3 clock plugin
import sublime
import sublime_plugin
from datetime import datetime
class ExampleCommand(sublime_plugin.EventListener):
# def printInConsole(self, text):
# print(text)
def updateClock(self, view):
timeArr = str(datetime.now().time()).split(':', 3)
@christianwish
christianwish / docu.py
Last active September 21, 2018 09:43
first-sublime.py
import sublime
import sublime_plugin
def getHtml(color, width):
html = '''
<body id="my-plugin-feature">
<style>
div.error , body , html {
@christianwish
christianwish / map.r
Created September 11, 2018 13:46
map functions for R
map.i <- function(fn, data) {
result <- c()
index <- 1
for (value in data){
result[index] <- fn(value, index)
index <- index + 1
}
return(result)
}
@christianwish
christianwish / settings.json
Created September 11, 2018 13:45
my vscode sttings
{
"window.zoomLevel": 1,
"workbench.colorTheme": "Monokai",
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"editor.fontSize": 13,
"editor.renderWhitespace": "all",
"editor.lineHeight": 24,
"files.trimTrailingWhitespace": true,
"editor.tabSize": 4,
func reduceArray<A,T>(
accFunc f: (A, T) -> A
, value v: [T]
, startValue sV: A
) -> A {
if v.count == 0 {
return sV;
}
originDataSrc <- "./data/survey_results_public.csv"
d <- read.csv(file = originDataSrc)
not.na <- function(context) { return(!is.na(context)) }
data.filter <- not.na(d$LanguageWorkedWith) & not.na(d$Gender) & d$Gender == "Female"
females <- d[data.filter,]
allLength <- length(d[,1])