Skip to content

Instantly share code, notes, and snippets.

@korakot
korakot / new_magic.py
Created April 11, 2018 10:01
Create a new cell magic in Jupyter (and Colab)
from IPython.display import HTML
from IPython.core.magic import register_cell_magic
# equivalent to %%js
@register_cell_magic
def myjs(line, cell):
return HTML(f'''
<script>
{cell}
</script>
@tkrs
tkrs / parser.go.y
Created February 13, 2018 05:31
goyacc tutorial
%{
package main
import (
"text/scanner"
"strconv"
"strings"
"fmt"
)
type Expression interface{}
type ParenExpr struct {
@jniltinho
jniltinho / install_setup_tidb.sh
Last active September 2, 2023 01:08
Install and Setup TiDB on Linux
#!/bin/bash
## Install and Setup TiDB on Linux
## https://github.com/pingcap/tidb
## https://github.com/pingcap/docs/blob/master/sql/privilege.md
## https://pingcap.com/blog/2016-10-17-how-we-build-tidb/
useradd tidb -d /var/lib/tidb -m
usermod -a -G tidb tidb
cd /var/lib/tidb
@rivo
rivo / postgres.go
Last active August 6, 2023 22:39
A demo Go application (a PostgreSQL database browser) highlighting the use of the rivo/tview package. See https://github.com/rivo/tview/wiki/Postgres
package main
import (
"database/sql"
"fmt"
"net/url"
"os"
"reflect"
"regexp"
"strconv"
#!/usr/bin/env python3
import sqlite3
import csv
import sys
quantize = '--quantize' in sys.argv
;;;; Dreaming of writing Vue frontends in a lispy way.
(defmacro defcomponent (name (&rest imports) &key template data style))
;; Goal:
;; Replicate http://vue-loader.vuejs.org/en/start/spec.html in CL
(defcomponent hello ()
:template (with-html
@heyimalex
heyimalex / sqlmap.go
Last active April 6, 2024 14:25
Functions for querying directly into map[string]interface{}
// Package sqlmap provides functions for querying directly into
// map[string]interface{}.
//
// In developing really simple api endpoints, I found the boilerplate needed
// to take the results of a database query and output them as JSON to be
// really fucking annoying; make a custom struct, scan into that struct, if
// there are multiple rows do the whole rows.Next() song and dance, and if
// anything changes update the three spots each column of the result is now
// dependent on. Even when using libraries like sqlx, there's still a lot of
// extraneous code that needs to be written.
@walm
walm / main.go
Last active February 27, 2024 08:22
Simple Golang DNS Server
package main
import (
"fmt"
"log"
"strconv"
"github.com/miekg/dns"
)
@neilodiaz
neilodiaz / vue-multiple-components.html
Last active August 6, 2020 14:07
VueJS 2.0 Multiple Components - To-Do app
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Multiple Components</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<link rel="stylesheet" type="text/css" href="">