{
"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 hidden or 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
git log @{u}.. | |
# @{u} is a shortcut to the upstream branch that this current branch is tracking. | |
# .. specifies a range of commits. | |
# same as saying git log @{u}..HEAD | |
# comparing where HEAD is on this branch to where HEAD is on the remote tracked branch.s | |
# https://stackoverflow.com/questions/19474577/what-does-the-argument-u-mean-in-git/19474730#19474730 |
This file contains hidden or 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 hidden or 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 = ?', '[email protected]', 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |