Skip to content

Instantly share code, notes, and snippets.

View mashingan's full-sized avatar

mashingan

View GitHub Profile
@mashingan
mashingan / hsql_parser.hs
Last active December 9, 2018 13:44
(Broken) Exploration of `Text.ParserCombinators.ReadP` package used to parse SQL create table syntax.
module SqlParser where
import Text.ParserCombinators.ReadP
import Data.Char (isAlpha)
--import Data.String.Utils
import qualified Data.Text as T
import Data.List
import qualified Data.Set as Set
import qualified Data.Map as M
import Data.Maybe
@mashingan
mashingan / download-manga.red
Created November 24, 2018 18:48
Mangastream web-scrapper and download the manga for each chapter. Translation of downloadmanga.nim
Red []
get-image: function [url] [
next-link: "" img-src: ""
parse read url [
thru {<div class="page">}
thru {<a href="}
copy next-link to {">}
thru {src="}
copy img-src to {" }
@mashingan
mashingan / sqlite3gorm.go
Last active March 4, 2025 00:25
Simple CRUD example working with Gorm
package main
import (
"fmt"
"net/http"
"strconv"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite"
"github.com/labstack/echo"
@mashingan
mashingan / null_length_js_karax.nim
Last active October 25, 2018 09:16
null length of cstrToNimstr using Karax
include karax/prelude
var
viewmain = true
viewsub = false
proc subRender: VNode =
proc subcb =
viewmain = true
viewsub = false
@mashingan
mashingan / crud_web.nim
Last active June 11, 2023 00:45
Simplistic crud example using Jester and Nim
# This example using
# Nim: 0.18.0
# Jester: 0.2.1
# Using Jester >= 0.3.0 is preferrable if your Nim version > 0.18.0
# In case you're using Jester >= 0.3.0, look the syntax different
# in its example because it's not backward compatible
import db_sqlite, asyncdispatch, json, strformat, strutils, sequtils
import jester
@mashingan
mashingan / translate.go
Created July 2, 2018 08:02 — forked from hvoecking/translate.go
Golang reflection: traversing arbitrary structures
// Traverses an arbitrary struct and translates all stings it encounters
//
// I haven't seen an example for reflection traversing an arbitrary struct, so
// I want to share this with you. If you encounter any bugs or want to see
// another example please comment.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Heye Vöcking
//
// from::
// http://stackoverflow.com/questions/11527935/ddg#11544854
package main
import (
"encoding/json"
"fmt"
"reflect"
)
@mashingan
mashingan / nest_basic.nim
Created December 23, 2017 15:03
Basic REST with nest
##
## Example of Nest that tracks how long routing takes
##
import nest
import logging
import asynchttpserver, strtabs, times, asyncdispatch, math
import httpcore
@mashingan
mashingan / start-stop-daemon-template
Created November 21, 2017 18:25 — forked from bcap/start-stop-daemon-template
Template file for creating linux services out of executables using the start-stop-daemon
#!/bin/bash
### BEGIN INIT INFO
# Provides: <service name>
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: <service description>
### END INIT INFO
@mashingan
mashingan / dataset3ID.csv
Last active October 15, 2017 17:43
Rough dbscans implementation with dataset3ID.csv as the data
ID X1 X2
10338001 -4.673253857 -0.612095787
10338002 -4.938803684 -0.469263745
10338003 -5.460488163 0.917422708
10338004 -5.363523692 -0.616513985
10338005 0.919264591 0.112761882
10338006 -1.309394745 -0.095029584
10338007 -4.033708861 -0.816182819
10338008 -1.588305433 -0.43439881
10338009 -1.118833043 1.356567282