View vue-expand-datatable.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<v-btn @click="explodeAll">{{exploded}}</v-btn> | |
<v-data-table | |
:headers="headers" | |
:items="items" | |
item-key="name" | |
ref="itemsTable" | |
expand | |
> | |
(..) |
View pg-sequence.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- lets play with sequences: | |
create table items (id serial primary key, name varchar(10)); | |
insert into items(name) values ('foo'); | |
-- manually insert into a serial is allowed BUT it breaks the sequence! | |
insert into items(id,name) values (2,'foo'); | |
-- now what do you expect? | |
select currval(pg_get_serial_sequence('items', 'id')); -- ouch! nextval is 1!! | |
-- ok, let's fix it up! | |
SELECT setval(pg_get_serial_sequence('items', 'id'), (select max(id)+1 from public.items)); |
View filesniff.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var allstats = filelist.map(filename => ({name: filename, path: path.parse(filename), stats: fs.statSync(filename) })); |
View select_latest_version.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET NOCOUNT ON | |
SET STATISTICS IO ON | |
DECLARE @t TABLE ( | |
Id INT IDENTITY(1,1) | |
, MyValue INT | |
, MyDate DATE | |
) | |
INSERT INTO @t VALUES(1,'2015-01-01') |
View node_working_dom_v1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
var jsdom = require('jsdom'); | |
var promise = require('promise'); | |
var colors = require('colors'); | |
var util = require('util'); | |
function get(url) { | |
return new Promise(function (resolve, reject) { | |
console.log('>>>'.yellow, 'started', 'get'.cyan, '[', url.yellow, ']'); |
View fileReadAndZip.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FileInfo fi = new FileInfo(fullpath); | |
String b64ZippedData = String.Empty; | |
using (FileStream filestream = fi.OpenRead()) // source | |
{ | |
using (MemoryStream memorystream = new MemoryStream()) // destination | |
{ | |
using (GZipStream gzipstream = new GZipStream(memorystream, CompressionMode.Compress, false)) // compression engine | |
{ | |
filestream.CopyTo(gzipstream); | |
} |
View file_post.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<meta charset="UTF-8"> | |
<head> | |
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> | |
</head> | |
<body> | |
<button id="uploadbtn">Click me to upload a file ...</button> | |
<form id="uploadform" action="sendfile" method="post" enctype="multipart/form-data" style="display:none"> | |
<input id="uploadfile" type="file" name="file1" > |
View multi-column-sort.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var items = [{name:"a", age:22}, { name:"b", age:11}, {name:"a", age: 10}] | |
var sortingfields = {name:true, age:true} // This is used as a dictionary. Sort by "name" DESC and "age" ASC | |
// do the items sort | |
items.sort((a,b) => { | |
for (col in sortingfields) { // added properties are positional | |
if (a[col] != b[col]) { // if they are equal, sorting is made on the next column | |
if (sortingfields[col] === true) return a[col] > b[col] // if ASC === true | |
else return a[col] < b[col] | |
} |
View handlebars-template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<meta charset="UTF-8"> | |
<head> | |
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.10/handlebars.min.js" crossorigin="anonymous"></script> | |
</head> | |
<body> | |
<div id="main"> | |
<script type="text/x-handlebars-template"> |