git format-patch -1 <sha>
OR
git format-patch -1 HEAD
git apply --stat file.patch # show stats.
git apply --check file.patch # check for error before applying
| #!/bin/bash | |
| echo "=============================================" | |
| echo "== Telegram Script Installer ==" | |
| echo "== ==" | |
| echo "== for www.LinuxRussia.com ==" | |
| echo "=============================================" | |
| echo "Downloading necesary files..." | |
| cd /tmp |
| HTMLElement.prototype.changeValueDetection = function(){ | |
| var element=this; | |
| var oldVal=element.value; | |
| var GUID = function (){var S4 = function () {return(Math.floor(Math.random() * 0x10000).toString(16));};return (S4() + S4() + "-" +S4() + "-" +S4() + "-" +S4() + "-" +S4() + S4() + S4());}; | |
| var uiq="GUID-"+GUID(); | |
| if(window.changeValueDetectionEvents==undefined)window.changeValueDetectionEvents=new Event('changeValueDetection'); | |
| element.setAttribute("data-uiq",uiq); | |
| window[uiq]=setInterval(function(){ | |
| if(element.value!=oldVal){ | |
| oldVal=element.value;element.setAttribute("value",oldVal); |
| #models.py | |
| class Task(models.Model): | |
| title = models.CharField(max_length=255) | |
| description = models.TextField() | |
| def __unicode__(self): | |
| return self.title |
| from django.core.management.base import BaseCommand | |
| from mymodule import main | |
| import logging | |
| class Command(BaseCommand): | |
| help = 'Do foo' | |
| def handle(self, *args, **options): |
| /* | |
| A (very) WIP collection of optimized/recommended jQuery plugin patterns | |
| from @addyosmani, @cowboy, @ajpiano and others. | |
| Disclaimer: | |
| ----------------------- | |
| Whilst the end-goal of this gist is to provide a list of recommended patterns, this | |
| is still very much a work-in-progress. I am not advocating the use of anything here | |
| until we've had sufficient time to tweak and weed out what the most useful patterns |
| from django.db import connection | |
| # If using cursor without "with" -- it must be closed explicitly: | |
| with connection.cursor() as cursor: | |
| cursor.execute('select column1, column2, column3 from table where aaa=%s', [5]) | |
| for row in cursor.fetchall(): | |
| print row[0], row[1], row[3] |
| ### Generic Dockerfile demonstrating good practices | |
| ### Imports | |
| # Bad-ish, we do not need Ubuntu for this, nor do we want latest if we are using in a build system, predictable is better | |
| FROM ubuntu:latest | |
| # Better, using a small image since our app has no dependency on Ubuntu | |
| FROM alpine:3.3 |
| #!/usr/bin/env | |
| # coding: utf-8 | |
| import asyncio | |
| import requests | |
| import tornado.gen as gen | |
| import tornado.httpclient as httpclient | |
| import tornado.httpserver as httpserver | |
| import tornado.options as options |
| import json | |
| import tornado.web | |
| class JsonHandler(BaseHandler): | |
| """Request handler where requests and responses speak JSON.""" | |
| def prepare(self): | |
| # Incorporate request JSON into arguments dictionary. | |
| if self.request.body: | |
| try: |