Skip to content

Instantly share code, notes, and snippets.

@szastupov
szastupov / styles.less
Last active January 14, 2017 20:45
If you like atom's OneDark syntax theme but think there is too much red in your JavaScript
.theme-one-dark-ui {
.syntax--variable {
color: inherit;
}
.syntax--this {
color: #e06c75;
}
}
import { deleteAt, updateObjectAt, swap } from '../../lib/farr'
export function defaultDataReducer(name, initialData = null) {
const initialState = {
[name]: initialData,
isFetching: true,
isFetched: false,
isRequested: false
}
@szastupov
szastupov / prom.js
Last active February 17, 2017 19:30
async function foo (bar) {
return bar + ' baz'
}
foo('test').then(console.log)
import sqlalchemy as sa
from sqlalchemy.ext.declarative import as_declarative, declared_attr
from sqlalchemy.orm import relationship, sessionmaker
engine = sa.create_engine('sqlite://')
Session = sessionmaker(bind=engine)
@as_declarative()
[
{
"key": "ctrl+1",
"command": "workbench.action.focusFirstEditorGroup"
},
{
"key": "ctrl+2",
"command": "workbench.action.focusSecondEditorGroup"
},
{
@szastupov
szastupov / console_log.swift
Created July 9, 2017 09:08
console.log() for jscore in swift
context.evaluateScript("var console = { log: function(...args) { _consoleLog(args.join(' ')) } }")
let consoleLog: @convention(block) (String) -> Void = { message in
print("console.log: " + message)
}
context.setObject(unsafeBitCast(consoleLog, to: AnyObject.self), forKeyedSubscript: "_consoleLog" as (NSCopying & NSObjectProtocol)!)
function compress(signal, threshold, ratio, makeup) {
return signal.map(x => {
let amp = Math.abs(x)
let sign = Math.sign(x)
if (amp > threshold) {
amp = (amp - threshold) * ratio + threshold
}
return sign * (amp * makeup)
})
}