Skip to content

Instantly share code, notes, and snippets.

Pierre Joubert pierrejoubert73

View GitHub Profile
jens1101 / data-url.js
Created May 22, 2018
Save Blob as file in JavaScript
View data-url.js
// In this file we use a data URL to represent a Blob. This basically base64
// encodes the Blob and puts that string in a URL. This has better compatibility
// with old browsers, but is limited to ~2MB.
const blob = getBlobFromSomewhere()
const reader = new FileReader()
reader.onload = function (event) {
const a = document.createElement('a')
a.href =
jens1101 / bootstrap-select-app.js
Last active May 22, 2018
An angular component wrapper for bootstrap select.
View bootstrap-select-app.js
var app = angular.module('app', [])
app.component('selectPicker', {
template: '<div ng-transclude ng-show="$"></div>',
require: {
ngModel: '^ngModel'
bindings: {
options: '<',
disable: '<'
jens1101 /
Created Jan 25, 2017
Should I use `ng-show` or `ng-hide`?

Often times the choice between both directives seems trivial, because you can achieve the same effect either way. However both have interesting default behaviours that you can use to you advantage.

  • ng-show will hide the element it is on by default, unless the condition in it evaluates to true.
  • ng-hide will show the element it is on by default, unless the condition in it evaluates to true.

This is most useful when your controller is doing AJAX calls or something else that's asynchronous. Your variables may still be undefined until the AJAX call returns.



jens1101 / controller.php
Created Oct 20, 2016
Posting data to Codeigniter via pure Angularjs
View controller.php
class User
public function save()
$username = $this->input->post('name');
$userData = json_decode($this->input->post('data'));
$doStuff($username, $userData);
jens1101 / arrayCopy-es5.js
Created Jul 28, 2016
Copy contents of one array into another without breaking references in JS
View arrayCopy-es5.js
function arrayCopy(to, from) {
Array.prototype.push.apply(to, from);
jens1101 / angular-upload.js
Last active May 22, 2018
Upload files via AJAX
View angular-upload.js
angular.module('uploadFile', []).service('uploadService', ['$http', function ($http) {
this.uploadFile = function () {
var field = document.createElement('input')
field.setAttribute('type', 'file')
field.setAttribute('accept', '.json, application/json')
field.onchange = function () {
var data = new FormData()
data.append('connectionId', 'banana')
data.append('fileToImport', field.files[0])
rgreenjr / postgres_queries_and_commands.sql
Last active Aug 3, 2020
Useful PostgreSQL Queries and Commands
View postgres_queries_and_commands.sql
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
You can’t perform that action at this time.