View vue-expand-datatable.vue
<v-btn @click="explodeAll">{{exploded}}</v-btn> | |
<v-data-table | |
:headers="headers" | |
:items="items" | |
item-key="name" | |
ref="itemsTable" | |
expand | |
> | |
(..) |
View pg-sequence.sql
-- 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
var allstats = filelist.map(filename => ({name: filename, path: path.parse(filename), stats: fs.statSync(filename) })); |
View select_latest_version.sql
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
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
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
<!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
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
<!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"> |