Skip to content

Instantly share code, notes, and snippets.

@tangoslee
tangoslee / pica-sample.vue
Created February 12, 2019 08:12
pica - vue.js
<template>
<div class="container">
<div class="col-sm-8">
<h3><button id='upload-btn' class="btn btn-secondary btn-xs" @click="onClick()">Upload</button></h3>
<h3>Preview</h3>
<div class="canvas-containter" id="preview-container">
<!-- <canvas id="preview-pica" class="img-responsive" style="max-width: 300px;"></canvas> -->
<img v-if="previewImage" :src="previewImage" style="max-width: 300px;">
</div>
@slightfoot
slightfoot / download.dart
Created April 13, 2018 22:14
Download file in Dart/Flutter
static var httpClient = new HttpClient();
Future<File> _downloadFile(String url, String filename) async {
var request = await httpClient.getUrl(Uri.parse(url));
var response = await request.close();
var bytes = await consolidateHttpClientResponseBytes(response);
String dir = (await getApplicationDocumentsDirectory()).path;
File file = new File('$dir/$filename');
await file.writeAsBytes(bytes);
return file;
}
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 4, 2024 06:22
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@zcaceres
zcaceres / Nested-Routers-Express.md
Last active April 4, 2024 09:44
Child Routers in Express

Nested Routers in Express.js

Express makes it easy to nest routes in your routers. But I always had trouble accessing the request object's .params when you had a long URI with multiple parameters and nested routes.

Let's say you're building routes for a website www.music.com. Music is organized into albums with multiple tracks. Users can click to see a track list. Then they can select a single track and see a sub-page about that specific track.

At our application level, we could first have a Router to handle any requests to our albums.

const express = require('express');
@marcoskubis
marcoskubis / table-ellipsis.css
Created February 24, 2017 13:08
Bootstrap table ellipsis
.table.table-ellipsis tbody td {
max-width: 100px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap
}
@dianjuar
dianjuar / Install update WordPress puglins directly.md
Last active April 16, 2024 12:21
Install update WordPress plugins without providing ftp access

Install WordPress plugins directly (without FTP)

Put this on your wp-config.php

/* That's all, stop editing! Happy blogging. */
define('FS_METHOD', 'direct');
@neguse11
neguse11 / node-js-mailgun-via-api.js
Created October 31, 2015 10:48
Call Mailgun API from node.js with Request
// node.js : Mailgun via API
var request = require('request')
var apiBaseUrl = 'https://api.mailgun.net/v3/sandboxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.mailgun.org';
var apiKey = 'key-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var from = 'Excited User';
var to = 'example@example.com';
var subject = 'Hello';
var text = 'Testing some Mailgun awesomness!';
@asleepwalker
asleepwalker / remove-polygon-holes.js
Last active December 4, 2021 05:13
Remove holes from multipolygons in geojson file
// DEPS: npm install jsts@0.17.0
// USAGE: node remove_holes.js holey_coverage.geojson solid_coverage.geojson
var fs = require('fs');
var jsts = require("jsts");
var parser = new jsts.io.GeoJSONParser();
var geojson = JSON.parse(fs.readFileSync(process.argv[2], 'utf8'));
var removedHoles = 0;
@ericelliott
ericelliott / defaults-overrides.md
Last active May 7, 2023 13:52
ES6 defaults / overrides pattern

ES6 Defaults / Overrides Pattern

Combine default parameters and destructuring for a compact version of the defaults / overrides pattern.

function foo ({
    bar = 'no',
    baz = 'works!'
  } = {}) {