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
#!/usr/bin/python | |
import sys | |
import requests | |
import json | |
headers = {'content-type': 'application/json'} | |
url = 'https://www.googleapis.com/urlshortener/v1/url' |
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
from django.utils.translation import activate | |
lang = request.GET['language'] | |
activate(lang) |
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
import pickle | |
# Session key | |
key = 'my_qs' | |
# Pizza => model example | |
qs = Pizza.objects.filter(ingredient='tomato') | |
# Dumping data | |
request.session[key] = pickle.dumps(qs.query) |
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( $ ){ | |
/* Global variables for the plugin */ | |
var defaults = { | |
timeout: 15 | |
}; | |
var settings = {}; | |
var form; |
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
from django.core.files import File | |
f = File(open('path_to_file','r')) | |
m = MyModel.objects.create(one_field='value') | |
m.file_field = f | |
m.save() |
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
#!/bin/bash | |
pg_dump mydb -U myuser | gzip > /home/user/db_backups/`date '+%Y-%m-%d-%H-%M'`.sql.gz |
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
!#/bin/zsh | |
createdb -E utf-8 mydb |
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
#!/bin/bash | |
# Next command will ask you for entering username/password | |
sudo -u postgres createuser -P | |
sudo -u postgres createdb mydb -O myuser |
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
#!/bin/bash | |
# Copying files from remote to local | |
# ---- | |
# Syncs remote '/home/user/sync_test' with local '/tmp/sync' | |
# You should run this command each time you need remote directory | |
# gets syncronized with your local one | |
rsync -avzhe ssh user@yourhost:/home/user/sync_test/ /tmp/sync |
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
#!/usr/bin/python | |
#------------------------------------------------------------------------ | |
# Gets public URL for a given Instagram photo ID. | |
# Example: http://instagram.com/p/h6qXCCmCJf/ => photo_id = h6qXCCmCJf | |
#------------------------------------------------------------------------ | |
import requests | |
import sys | |
import json |
OlderNewer