Skip to content

Instantly share code, notes, and snippets.

@bq1990
bq1990 / gist:5a0f037c13b312b68bcc
Last active August 29, 2015 14:25
Flask edit Stormpath account
@app.route('/account/edit', methods=['GET', 'POST'])
@login_required
def edit_account():
sp = app.stormpath_manager.client
form = AccountForm(request.form, obj=user,
company_name=user.custom_data.get('company', None))
if form.validate_on_submit():
try:
_user = sp.accounts.get(user.href)
_user.email = form.email.data
angular.module('myModule', []).controller('ctrl', function($scope) {
}).directive('overflowY', ['$window', '$document', function($window, $document) {
return {
link: function(scope, element, attrs) {
var w = angular.element($window);
var raw = element[0];
var atBottom = false,
@bq1990
bq1990 / gist:f64a71063ba5fe11b92b
Created May 27, 2015 21:30
Check for attribute in a list of objects
any(group.name == "admin" for group in user.groups)
@bq1990
bq1990 / gist:7aa4c07a4d8327688da2
Created February 28, 2015 19:47
Mysql backup/restore
backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
restore:# mysql -u root -p[root_password] [database_name] < dumpfilename.sql
@bq1990
bq1990 / gist:8b0e0c4fb9ae0b9f34e3
Created February 26, 2015 21:30
Javascript pretty json
function prettyJSON(obj) {
console.log(JSON.stringify(obj, null, 2));
}
// obj -> value to convert to a JSON string
// null -> (do nothing)
// 2 -> 2 spaces per indent level
<rule name="san aspx">
<!--Removes the .aspx extension for all pages.-->
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}.aspx" />
</rule>
@bq1990
bq1990 / gist:a0ef79b87bae81e6b870
Created January 31, 2015 19:10
Linux zip recursively
zip -rv9 myzipfile.zip /mydir
$ nohup ./myprogram > foo.out 2> foo.err < /dev/null &
@bq1990
bq1990 / gist:dd75f21c628d744cb56c
Last active August 29, 2015 14:13
bootstrap3 template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
@bq1990
bq1990 / gist:4f24eca04fe006ccf1e5
Created January 2, 2015 06:36
Knex seed example
'use strict';
var users = require('../sample_users');
exports.seed = function(knex, Promise) {
var userPromises = [];
users.forEach(function(user){
userPromises.push(createUser(knex, user));
});
return Promise.all(userPromises);
};