Skip to content

Instantly share code, notes, and snippets.

View mdimai666's full-sized avatar
🏠
Working from home

mdimai666 mdimai666

🏠
Working from home
View GitHub Profile
@mdimai666
mdimai666 / script.js
Created August 7, 2017 00:21
Test gist
$(function(){
alert(1);
});
@mdimai666
mdimai666 / jQueryKeyBind.js
Last active April 6, 2018 05:00
key bind script for jquery
function ready_keyBind(){
$(function(){
var schema = [
{key:'s', fn: d_save, args: []}
];
for(var k of schema)
$.ctrl(k.key,k.fn,k.args);
})
@mdimai666
mdimai666 / pgsql-query-size-and-rowCount.sql
Last active August 1, 2018 03:46
Postgres Return statistic(size, rows count) from all tables in current DataBase
/*
Return statistic from all tables in current DataBase
+------------------+----------+-------+--------------+
| tableName | rowCount | size | externalSize |
+------------------+----------+-------+--------------+
| mails | 101 | 64kb | 48kb |
+------------------+----------+-------+--------------+
| "logs" | 25 | 104kb | 56kb |
+------------------+----------+-------+--------------+
[
{
"id": "179c3813.5b8248",
"type": "function",
"z": "f2af3e46.9dad5",
"name": "random url",
"func": "var ran = Math.random()*1000 | 0;\n// msg.url = 'https://www.google.ru/search?q='+ran+'&sourceid=chrome&ie=UTF-8';\n// msg.url = 'https://www.bing.com/search?q='+ran+'&sourceid=chrome&ie=UTF-8';\nmsg.url = 'http://randomtextgenerator.com/';\n\nmsg.payload = {\n text_mode: 'plain',\n language:'en',\n Go:'Go'\n}\nmsg.headers = {'Accept-Language':'en'};\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 334,
[
{
"id": "18c14b4b.131de5",
"type": "function",
"z": "4e51036c.b5a04c",
"name": "gen Query",
"func": "var jj = global.get('jj'); //JSON safe stringify\n\ntry {\n var sql = \"INSERT INTO logs (code,source,title,body,json,screenshot,uid)\";\n sql += \" VALUES \";\n var v = msg.payload;\n \n if(typeof msg === 'string') return;\n \n var a = [v.code,\n escapeQuote(escapeObj(v.source)||'node-red').slice(0,100),\n escapeQuote(v.title).slice(0,200),\n escapeQuote(escapeObj(v.body||'node body')),\n escapeQuote(jj(v.json)),\n '',v.uid];\n \n // node.warn(a);\n a = a.map(s=>`'${s}'`).join(',');\n sql += `(${a})`;\n msg.topic = sql;\n msg.payload = '';\n return msg;\n} catch (err){\n node.error(err);\n}\n\n\nfunction escapeObj(va){\n if(typeof va === 'string')\n return va;\n else return jj(va)\n}\n\nfunction escapeSP(v) {\n // return v\n // .repla
[
{
"id": "6ca1909c.71f58",
"type": "inject",
"z": "f2af3e46.9dad5",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
[
{
"id": "82919dfb.c477c",
"type": "inject",
"z": "826a56c3.fa3198",
"name": "",
"topic": "",
"payload": "ARR",
"payloadType": "global",
"repeat": "",
[
{
"id": "a943ef88.f0d67",
"type": "function",
"z": "3f9b5a25.189626",
"name": "loop",
"func": "if(msg.loop_array.length<1)\n return [null,msg];\n \nmsg.loop_current = msg.loop_array.shift();\nmsg.payload = msg.loop_current;\n\nreturn [msg]",
"outputs": 2,
"noerr": 0,
"x": 401,
function array_move(arr, old_index, new_index) {
if (new_index >= arr.length) {
var k = new_index - arr.length + 1;
while (k--) {
arr.push(undefined);
}
}
arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
return arr; // for testing
};
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css", rel="stylesheet", integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u", crossorigin="anonymous">