Skip to content

Instantly share code, notes, and snippets.

@christianwish
christianwish / simple-masonry-columnlength.js
Last active February 7, 2016 18:24
simple-masonry.js examples
simpleM.columnsLength()
// returns number of available colums
@christianwish
christianwish / update-node-npm.md
Last active October 15, 2016 14:28
Update node.js & npm to latest version

update node.js

$ npm cache clean -f
$ npm install -g n
$ n stable

##update npm

$ npm install npm@latest -g
@christianwish
christianwish / sketch-app-plugin-json.js
Created October 21, 2016 11:18
Get json data by url in sketch plugin
function get(queryURL) {
var request = NSMutableURLRequest.new();
[request setHTTPMethod:@"GET"];
[request setURL:[NSURL URLWithString:queryURL]];
var error = NSError.new();
var responseCode = null;
var oResponseData = [NSURLConnection sendSynchronousRequest:request returningResponse:responseCode error:error];
@christianwish
christianwish / manifest.json
Last active July 20, 2018 02:42
inject js by chrome extension
{
"name": "inject script",
"description": "",
"version": "1.0",
"permissions": [
"tabs", "http://*/*", "https://*/*"
],
"browser_action": {
"default_title": "Set this page's color.",
"default_icon": "icon.png",
@christianwish
christianwish / my-atom.md
Last active August 13, 2018 12:14
My Atom Settings
apm install docblockr
apm install minimap
apm install atom-typescript
apm install monokai
apm install atom-beautify
apm install atom-clock
apm install git-blame
apm install pigments
apm install language-haskell
# pythonw ./index.py
# clear terminal !!! Cool
# print("\033[H\033[J")
CRED = '\033[91m'
CEND = '\033[0m'
def logError(msg, info):
@christianwish
christianwish / createA.graphql
Last active July 5, 2018 08:18
graphql relation mutation
# Step 1
# To create a B you have to create a A first
mutation {
createA(
title: "first A!"
) {
id
}
}
type LineNumber = Int
type ColumnNumber = Int
data Identifier = Identifier {
typeId :: String
, value :: String
, position :: (LineNumber, ColumnNumber)
, children :: [Identifier]
} deriving (Show)
@christianwish
christianwish / infinite.hs
Created July 20, 2018 06:27
timeout haskell
import System.IO
import Control.Concurrent (threadDelay)
a i = do
threadDelay 1000000
print $ show i
a (i + 1)
main = do
a 0
const headToTail = (i, v) => (v.substring(i) + v.substring(0, i));
const createSharedId = str => str
.split('')
.reduce((acc, a) => ([...acc, headToTail(acc.length, str.toLowerCase())]), [])
.sort()[0];
const valueReducer = (acc, { src, sharedId }) => (typeof acc[sharedId] === 'undefined')
? { ...acc, [sharedId]: [src] }
: { ...acc, [sharedId]: [ ...acc[sharedId], src] };