Skip to content

Instantly share code, notes, and snippets.

@quant61
quant61 / notes-1.md
Last active February 15, 2020 21:02
public random notes

I have lots of notes in my local files and also I plan to move them to gists.

// TODO: improve&refactor

// symfony convert request body to array:
@quant61
quant61 / sql search notes.sql
Created May 7, 2017 18:05
notes on search in mysql
/*
* searching some values in mysql is not as easy as you think
* some search may not work way you think
* for example, it's virtually impossible to search NULL values
* without `IS NULL`
*
* you can test this queries using your local mysql or online services like sqlfiddle
*
*/
@quant61
quant61 / mixValue.js
Last active February 23, 2017 08:32
getting javascript value of random type
// special Javascript values
const specials = [null, true, false, undefined, NaN, 1/0, -1/0, -0];
function getMixValue(){
return randIndex([
randSpecial,
randInt,
randFloat,
randStr,
@quant61
quant61 / Javascript_toNumber.md
Last active January 10, 2023 11:58
conversion to number in javascript

Some notes about conversion to number in javascript

javascript has lots of methods to convert any value to number

  • all methods could be divided into 2 groups: string and native methods
    • String methods are parseInt and parseFloat
    • Native mathods are Number and Math methods

all native methods behave the same way, sometimes with additional transform

@quant61
quant61 / 0
Last active February 9, 2018 19:42
PublicGist0
some esoteric ES6 functions
var getDiagonalMatrix = N=>Array(N).fill(0).map((x,i)=>Array(N).fill(i).map((x,j)=>i==j?1:0));
var getNDArray = (N, x)=>N.length?(Array(N[0]).fill(0).map(()=>arr(N.slice(1),x))):x;
var toBase = (x,n,r=[])=>x ? toBase(Math.trunc(x/n), n, [ x%n, ...r]):r;