Skip to content

Instantly share code, notes, and snippets.

View vyach-vasiliev's full-sized avatar

ฬะทçะรโลนร vyach-vasiliev

  • Milky Way galaxy, planet Earth
View GitHub Profile
@paulirish
paulirish / gist:601751
Created September 28, 2010 20:50
localStorage and sessionStorage should accept objects
// desire: localStorage and sessionStorage should accept objects
// in fact they do according to spec.
// http://code.google.com/p/chromium/issues/detail?id=43666
// but so far that part isnt implemented anywhere.
// so we duckpunch set/getItem() to stringify/parse on the way in/out
// this seems to work in chrome
// but fails in FF (cant redefine setItem as a function, it just tostring's it)
@virtualstaticvoid
virtualstaticvoid / iptables_rules.sh
Created June 14, 2011 08:58
25 Most Frequently Used Linux IPTables Rules Examples
# Modify this file accordingly for your specific requirement.
# http://www.thegeekstuff.com
# 1. Delete all existing rules
iptables -F
# 2. Set default chain policies
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
@jqb
jqb / admin.py
Created August 22, 2011 14:34
Django signals sample
# -*- coding: utf-8 -*-
import warnings
from django.db.models.signals import post_save
from django.contrib import admin
from django.contrib.sites.models import Site
from django.contrib.auth.models import Group, User
from django.contrib.auth.admin import UserAdmin as AuthUserAdmin
from django.utils.translation import ugettext, ugettext_lazy as _
@madyankin
madyankin / composition-normalization-and-morons.markdown
Created March 2, 2012 07:19 — forked from julik/composition-normalization-and-morons.markdown
Композиция, нормализация и уроды

В своих разговорах о Юникоде я не затронул несколько интересных моментов, о которых полезно знать. Кофейный столик "Юлик о Юникоде" продолжает прием посетителей.

Байт, кодпойнт, глиф

Юникод - многобайтовый способ кодирования текста. Текст состоит из codepoints (кодовых позиций), все позиции присутствуют в каталоге символов Unicode. Кодпойнты включают базовые компоненты графем и графемы в целом. При этом:

Каждый кодпойнт можно выразить в байтовом виде как минимум 5 разными способами

Один из них - UTF-8, в котором все латинские буквы заменены на однобайтовые ASCII-эквиваленты. Другие варианты - UTF-16 и UTF-32. UTF-16 - стандартный способ хранения Unicode-строк в операционных системах. InDesign импортирует тексты именно в UTF-16 например.

@ndarville
ndarville / secret-key-gen.py
Created August 24, 2012 17:01
Generating a properly secure SECRET_KEY in Django
"""
Two things are wrong with Django's default `SECRET_KEY` system:
1. It is not random but pseudo-random
2. It saves and displays the SECRET_KEY in `settings.py`
This snippet
1. uses `SystemRandom()` instead to generate a random key
2. saves a local `secret.txt`
@mdeverdelhan
mdeverdelhan / AsyncMailSender.java
Last active June 21, 2019 19:31
Exception interception (AOP) and asynchronous mail sending with Spring
package com.mygroup.myapp.common.task;
import org.springframework.mail.MailException;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.scheduling.annotation.Async;
/**
* Asynchronous mail sender
*/
@sspross
sspross / DJANGO_TWISTED_HAPROXY.md
Last active November 13, 2023 03:15
Serving Django and Twisted using HAproxy

Serving Django and Twisted using HAproxy

Why?

Because we wanted to achive the following while developing a webapp using websockets:

Static serving (nginx), Django application (gunicorn) and Websockets service (twisted)

  • on the same IP
@robatron
robatron / javascript-log-wrapping.md
Last active February 6, 2024 06:49
Wrapping `console.log` (et al.) in your own function to modify logging behavior.

JavaScript Log Wrapping

Wrapping console.log (et al.) in your own function to modify logging behavior.

Why?

You may want a simple way to:

@amjith
amjith / wsgi_app.py
Created June 4, 2013 00:09
WSGI app to test the NR disable/enable.
from time import sleep
from webtest import TestApp
import newrelic.agent
newrelic.agent.initialize('newrelic.ini')
def hello_world(environ, start_response):
path = environ.get('PATH_INFO')
if path.startswith('/slow'):
@kendellfab
kendellfab / goto-sublime
Created August 1, 2013 20:53
Add mouse click `goto definition` in sublime text 3.
Linux - create "Default (Linux).sublime-mousemap" in ~/.config/sublime-text-3/Packages/User
Mac - create "Default (OSX).sublime-mousemap" in ~/Library/Application Support/Sublime Text 3/Packages/User
Win - create "Default (Windows).sublime-mousemap" in %appdata%\Sublime Text 3\Packages\User
[
{
"button": "button1",
"count": 1,
"modifiers": ["ctrl"],
"press_command": "drag_select",