Skip to content

Instantly share code, notes, and snippets.

@madox2
madox2 / vim-tips.prompt.vimai
Created March 7, 2023 08:35
vim-ai: vim tips prompt
>>> system
You are an VIM tutor. You give a short and useful tips on using VIM, useful commands, etc. Start every answer with "Did you know"
>>> user
give me a vim tip
<<< assistant
@madox2
madox2 / kdice-autoendturn.js
Created April 25, 2020 18:25
Enables auto-end turn for KDice
// ==UserScript==
// @name KDice Auto-end turn
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Auto-end turn for KDice
// @author You
// @match https://kdice.com/*
// @grant none
// ==/UserScript==
@madox2
madox2 / serve-prod-build.js
Last active April 14, 2019 14:01
node js server that serves static folder and makes proxy to api server
var proxy = require('express-http-proxy')
var express = require('express')
var app = express()
// e.g. I want to serve app from local dir on localhost:8000/app
// and use API from remote server http://myserver/api
const localAppStaticDir = '../somedir/someapp/build'
const localAppPath = '/app'
const localApiPath = '/api'
@madox2
madox2 / jsconfig.json
Created November 17, 2018 08:43
Default config for js projects
{
"compilerOptions": {
"checkJs": false,
"allowJs": true,
"noEmitOnError": true,
"noEmit": true,
"target": "es6",
"module": "commonjs",
"jsx": "react"
},
@madox2
madox2 / snippets.js
Created August 8, 2017 18:46
Snippets to prettify
const a = {b: 1, c: 2}
cost Component = () => (
<div prop={1}
other={2} />
)
import { hahahahahahaha, heheheheheheh, huhuhuhuhuhu, hihihihihihi, hohohohoho } from 'react-hahahaha-heheheh-huhuhu'
function foo(
@madox2
madox2 / git_lg_alias
Created November 9, 2016 22:40
git lg alias
git config --global alias.lg "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"
@madox2
madox2 / vim_eslint_fix.vim
Created October 12, 2016 16:22
Function which runs eslint --fix and saves the buffer. It is mapped to :W command
function ESLintFix()
write
silent execute "!./node_modules/.bin/eslint --fix %"
edit! %
redraw!
endfunction
command W call ESLintFix()
import React, { Component } from 'react'
import { theme, Text, View, withStyles } from 'react-native-themeable'
const redTheme = withStyles([
{
$type: Text,
color: 'white',
fontSize: 26,
}, {
$type: View,
@madox2
madox2 / windows-1250_to_utf-8.py
Created August 26, 2016 18:56
Could be useful when encoding subtitles
#!/usr/bin/python
import sys
import urllib
source_enc = 'windows-1250'
target_enc = 'utf-8'
print '============================================='
print '=== conversion from windows-1250 to utf-8 ==='
print '============================================='
@madox2
madox2 / intercept_module.js
Last active August 10, 2016 20:28
intercepting module in node
const M = require('module')
const _load = M._load;
M._load = function(request, ...rest) {
const _module = _load(request, ...rest)
if (request === './module1.js') {
return function(...args) {
console.log(`intercepting ${request}`)
_module(...args)
}