Skip to content

Instantly share code, notes, and snippets.

View decadef20's full-sized avatar
🎯
Focusing

Decade decadef20

🎯
Focusing
View GitHub Profile
@decadef20
decadef20 / golang.middleware.go
Last active June 2, 2020 09:51
golang middleware
package main
import "net/http"
import "fmt"
import "log"
type MyResponseWriter struct {
http.ResponseWriter
code int
}
package main
import (
"fmt"
)
func digits(number int, dchnl chan int) {
for number != 0 {
digit := number % 10
// how to add ts interface by babel-types
const interfaces = path.insertAfter(
t.tSInterfaceDeclaration(
t.identifier('State'),
null,
null,
t.tsInterfaceBody(
[ t.tsPropertySignature(t.stringLiteral('test'), t.tsTypeAnnotation(t.TSLiteralType(t.stringLiteral('string')))) ]
)
)
@decadef20
decadef20 / delete_git_submodule.md
Created December 4, 2019 06:33 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@decadef20
decadef20 / git-number-of-lines.bash
Last active September 4, 2019 03:42
Count number of lines in a git repository
git ls-files | xargs cat | wc -l
git ls-files | xargs wc -l
@decadef20
decadef20 / read-directories.js
Created August 29, 2019 02:37
nodejs read directories
const { lstatSync, readdirSync } = require('fs')
const { join } = require('path')
const isDirectory = source => lstatSync(source).isDirectory()
const getDirectories = source =>
readdirSync(source).map(name => join(source, name)).filter(isDirectory)
@decadef20
decadef20 / node-connect-mongodb.js
Created March 21, 2018 04:55
nodejs connect mongodb
const request = require('request');
const fs = require('fs');
const MongoClient = require('mongodb').MongoClient;
const dbUrl = "mongodb://localhost:27017/dbname";
const url = '';
const ids = 1000000;
const base = 1;
const downloading = [];
const genOptions = (id)=> ({