{
"name": "todo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "./node_modules/.bin/webpack-dev-server --inline --hot",
"test": "echo \"Error: no test specified\" && exit 1"
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
sudo chown -R $USER ~/projects/kaa-api/log |
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
# rails 2.3.5 | |
p = Promotion.find(:first, :conditions => ["subdomain = ?", "foobar"]) | |
# to find based on multiple conditions based on multiple associations | |
User.find(:all, :include => [:contact, :promotion], :conditions => ['contacts.email = ? and promotions.id = ?', 'marcuss@hesonline.com', 22]) | |
# to find last record in old rails apps, rails 2 | |
p = Promotion.find(:all, :order => "id desc", :limit => 1) # newest first | |
# and in ascending order | |
p = Promotion.find(:all, :order => "id asc", :limit => 1) # oldest first |
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
function ajax(type, url){ | |
return new Promise(function(resolve, reject){ | |
var http_request = new XMLHttpRequest(); | |
http_request.open(type, "http://127.0.0.1:8000/"+ url); | |
http_request.onload = function() { | |
if (http_request.status === 200){ | |
resolve(JSON.parse(http_request.response)); | |
} else { | |
reject(Error(http_request.statusText)); | |
} |
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
function is_empty(obj){ | |
return Object.keys(obj).length === 0; | |
} | |
// alternative | |
function isEmpty(object) { | |
for(var i in object) { | |
return true; | |
} | |
return false; |
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
psql -h 999.999.99.99 -U web_forms web_forms | |
web_forms=> SELECT * from django_migrations; | |
web_forms=> DELETE FROM django_migrations WHERE id=28; | |
web_forms=> DROP TABLE room_change_request_type; | |
# drop all tables from that app | |
web_forms=> \q | |
./manage.py migrate |
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
django-csrf-token.js | |
import React from 'react'; | |
export default class DjangoCSRFToken extends React.Component { | |
render(){ | |
var csrf_token = getCookie('csrftoken'); | |
return (<input type="hidden" name="csrfmiddlewaretoken" value={ csrf_token }/>); | |
} |
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 element = document.querySelector("#foo"); | |
var element_details = element.getBoundingClientRect(); | |
var element_width = element_details.width; | |
var element_height = element_details.height; |
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
appendChild |
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
function get_selected_values(select_element){ | |
/* | |
Vanilla JS way of returning an array of selected elements from a | |
select element with multiple='mulitple'. | |
Used to allow for multiple Evaluation Categories to be | |
selected. | |
*/ | |
var result = []; | |
var options = select_element && select_element.options; | |
var opt; |