Skip to content

Instantly share code, notes, and snippets.

@asm-jaime
asm-jaime / go-gin-mgo.go
Last active February 20, 2021 21:13
go gin mgo, gin+mongo+test example
package main
import (
"encoding/base64"
"fmt"
rand "math/rand"
"time"
"github.com/gin-gonic/gin"
@asm-jaime
asm-jaime / get_tags.js
Created May 27, 2017 20:26
get all tags from a text (javascript), '#dfgdgf fgsdfg fgfgfgfg #gg' to ['#dfgdgf', '#gg'].
function get_tags(text) { //{{{
console.time('algs tags time');
const tags = [];
const txt = text.trim().split('');
let reg_tag = false;
let cur_tag = '';
for (let i = 0; i < txt.length; i++) {
if (reg_tag && txt[i] === '#') {
@asm-jaime
asm-jaime / index.html
Created November 22, 2017 11:38
d3+redux example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.7.2/redux.min.js"></script>
</head>
<body>
<script>
const initialState = {
@asm-jaime
asm-jaime / mgo.go
Last active December 24, 2017 04:58
go mgo mongodb+test example, test insert same data to unique key
package main
import (
mgo "gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"time"
)
// ========== model
@asm-jaime
asm-jaime / tree_walker.js
Created May 4, 2018 14:50
this javascript example about tree traversal with use recursion and simple cycle while
// ========== data
const data = [{
"value":49,
"childs":[
{"value":54, "childs":[
{"value":25, "childs":[{"value":5, "childs":[]},{"value":5, "childs":[]}]},
{"value":15, "childs":[{"value":25, "childs":[]},{"value":125, "childs":[]},{"value":625, "childs":[]},{"value":55, "childs":[]}]},
{"value":35, "childs":[{"value":25, "childs":[]}]}
]},
{"value":55, "childs":[{"value":85, "childs":[]},{"value":45, "childs":[]},{"value":25, "childs":[]}]},
@asm-jaime
asm-jaime / 1234.html
Created May 8, 2018 20:14
1234 mutation and diffs
<!DOCTYPE html><html><head><style type="text/css">
#main_wrapper {
margin: 0;
padding: 0;
overflow: none;
}
.nvtooltip {
position: absolute;
background-color: rgba(255,255,255,1);
@asm-jaime
asm-jaime / 12345.html
Created May 8, 2018 20:16
12345 mutations and diffs
<!DOCTYPE html><html><head><style type="text/css">
#main_wrapper {
margin: 0;
padding: 0;
overflow: none;
}
.nvtooltip {
position: absolute;
background-color: rgba(255,255,255,1);
@asm-jaime
asm-jaime / index.html
Last active May 10, 2018 08:14
one file MVC
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>pistonizator</title>
</head>
<body style="text-align: center; font-size: 24px;">
<p>MVC</p>
<img id="mainv" src="http://fb.ru/misc/i/gallery/51506/2272349.jpg"></img>
<br/>
@asm-jaime
asm-jaime / braces_valid.js
Last active May 12, 2018 05:04
javascript braces validation, with use array and object as dictionary
// ========== array brace validation
const edict_arr = [
['[', ']'],
['(', ')'],
['{', '}'],
];
function valid_arr(braces){
@asm-jaime
asm-jaime / index.html
Last active May 17, 2018 16:40
good grid+flexbox
<!DOCTYPE html>
<html lang="en">
<head>
<title>pr</title>
<style>
body {
margin: 0px;
padding: 0px;