Skip to content

Instantly share code, notes, and snippets.

View Maqsim's full-sized avatar

Max Diachenko Maqsim

View GitHub Profile
@d-srd
d-srd / DarkMode.swift
Last active September 29, 2019 15:53
enum DarkMode {
static var isEnabled: Bool {
let script = """
tell application "System Events"
tell appearance preferences
get properties
return dark mode
end tell
end tell
"""
@Maqsim
Maqsim / 413-payload-too-large-fix.js
Last active April 30, 2024 20:36
HOW TO FIX "413 Payload too large" in NodeJS (Express)
const express = require('express');
const bodyParser = require('body-parser');
...
// Express 4.0
app.use(bodyParser.json({ limit: '10mb' }));
app.use(bodyParser.urlencoded({ extended: true, limit: '10mb' }));
// Express 3.0
@Maqsim
Maqsim / hex-to-bgr.js
Created February 13, 2018 23:12
HEX to BGR
'#ff2233'.substr(1).match(/.{2}/g).reverse().join('')
@gf3
gf3 / Spotify.swift
Created August 29, 2017 20:55
Spotify ScriptingBridge from Swift
import AppKit
import ScriptingBridge
@objc public protocol SBObjectProtocol: NSObjectProtocol {
func get() -> Any!
}
@objc public protocol SBApplicationProtocol: SBObjectProtocol {
func activate()
var delegate: SBApplicationDelegate! { get set }
@crisbit
crisbit / ElapsedTime.swift
Created December 14, 2016 13:10
Calculate elapsed time in Swift
let start = Date()
print("Elapsed time: \(start.timeIntervalSinceNow) seconds")
@nikgraf
nikgraf / reactive-2016.md
Last active August 5, 2021 15:31
Proposal for lightning talk at Reactive Conf 2016

Rich text editing with DraftJS Plugins

Earlier this year Facebook open sourced its React based rich text editing framework Draft.js. At Facebook it powers status updates, comments & notes. Others used it to build editors matching Medium’s experience.

Together with a whole team of open source contributors I built a plugin architecture on top of Draft.js. In this talk I walk you through the existing plugins and show how you can build your own feature-rich text editor for the web with only a handful lines of code. 🤓

Draft JS Plugins Logo

@shawnbot
shawnbot / form-save.js
Last active July 29, 2021 14:54
A JavaScript snippet for temporarily saving and restoring a form's state after refreshing
// NOTE: the '#form-id' selector below will most certainly be different
// for whatever page you're on. Remember to change it in both instances!
// run this in the terminal to save the state of your form
// in your browser's LocalStorage:
[].forEach.call(document.querySelector('#form-id').elements, function(el) {
localStorage.setItem(el.name, el.value);
});
// then refresh the page and run this to restore your form values:
@mikaelbr
mikaelbr / destructuring.js
Last active April 25, 2024 13:21
Complete collection of JavaScript destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@EpokK
EpokK / ngEnter.js
Last active January 7, 2022 13:57
ngEnter directive if you can use submit form(https://twitter.com/ririlepanda)
app.directive('ngEnter', function() {
return function(scope, element, attrs) {
element.bind("keydown keypress", function(event) {
if(event.which === 13) {
scope.$apply(function(){
scope.$eval(attrs.ngEnter);
});
event.preventDefault();
}
@willurd
willurd / web-servers.md
Last active May 7, 2024 04:58
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000