Skip to content

Instantly share code, notes, and snippets.

View xfenix's full-sized avatar
😏
All commits are lost

Denis xfenix

😏
All commits are lost
View GitHub Profile
@xfenix
xfenix / gist:2764829
Created May 21, 2012 21:25
Shadowbox next/prev lightbox-like navigation implementation
Shadowbox.init({
onFinish : function(az) {
var navBtnRight = $("<div/>").addClass('shadowbox-nav shadowbox-next').html($("<a/>") .click(function(){Shadowbox.next();}));
var navBtnLeft = $("<div/>").addClass('shadowbox-nav shadowbox-prev').html($("<a/>").click(function(){Shadowbox.previous();}));
$("#sb-body-inner").prepend(navBtnRight )
.prepend(navBtnLeft);
$('.shadowbox-nav').hover(
function() {
if(
@xfenix
xfenix / myTooltip.js
Created June 1, 2012 09:04
Shitty jquery tooltip, aTooltip based, update soon (never?)
(function($) {
$.fn.myTooltip = function(options) {
/**
setup default settings
*/
var defaults = {
closeTipBtn: 'aToolTipClose',
closeTipBtnClass: 'tooltip-close',
toolTipId: 'aToolTip',
toolTipClass: 'tooltip',
@xfenix
xfenix / gist:2988281
Created June 25, 2012 12:22
PHP function for bright hex color
<?
function hexLighter($hex,$factor = 30) {
$new_hex = '';
$hex = str_replace('#', '', $hex);
$base['R'] = hexdec($hex{0}.$hex{1});
$base['G'] = hexdec($hex{2}.$hex{3});
$base['B'] = hexdec($hex{4}.$hex{5});
foreach ($base as $k => $v) {
@xfenix
xfenix / gist:3206768
Created July 30, 2012 13:10
Django sendmail backend
"""sendmail email backend class."""
import threading
from django.conf import settings
from django.core.mail.backends.base import BaseEmailBackend
from subprocess import Popen,PIPE
class EmailBackend(BaseEmailBackend):
def __init__(self, fail_silently=False, **kwargs):
@xfenix
xfenix / gist:3314707
Created August 10, 2012 14:39
EnglishToRussian conversion table
table = function(code) {
var s = 'фисвуапршолдьтщзйкыегмцчня',
b = 'ФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯ',
c = s.length,
A = [],
A2 = [],
A3 = {91: 'х', 93: 'ъ', 59: 'ж', 39: 'э', 44: 'б', 46: 'ю', 123: 'Х', 125: 'Ъ', 58: 'Ж', 34: 'Э', 60: 'Б', 62: 'Ю'},
T = [],
sk = 96,
bk = 64;
@xfenix
xfenix / gist:3314714
Created August 10, 2012 14:41
Drupal pg2mysql migration helper
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os, errno, re, psycopg2
# конфигурация
dsn = 'dbname=stiebel user=postgres password=111 port=5434'
table = 'menu_router'
fields = ['load_functions', 'to_arg_functions', 'access_arguments', 'page_arguments', ]
pk = 'path'
file = '/web/data.sql'
@xfenix
xfenix / base_site.html
Created September 5, 2012 14:22
Grappelli ckeditor simple integration with solved collapsable problem and django-filebrowser
{% extends "admin/base.html" %}
{% load i18n %}
{% block extrahead %}
<script type="text/javascript" src="/static/ckeditor/ckeditor.js"></script>
<script type="text/javascript">
grp.jQuery(function(){
config = {
'toolbar': [
[
@xfenix
xfenix / modalwindowimageheightfix.js
Created September 19, 2012 13:58
This script allow dynamically load content with images, that has no height attribute. Nyromodal version.
var secret = $('<div>').attr('id', 'secret-meter'),
loadNow = 0,
loadTotal = 0;
$('body').prepend(secret);
$('.dialog').click(function(){
var url = $(this)[0].href,
loadWindow = function() {
$.nmData(secret.html(), {
closeButton: '<a href="#" class="nyroModalClose nyroModalCloseButton nmReposition" title="close"></a>',
@xfenix
xfenix / transliterate.py
Created September 20, 2012 11:24
Transliterate functions
def translit(locallangstring):
conversion = {
u'\u0410' : 'A', u'\u0430' : 'a',
u'\u0411' : 'B', u'\u0431' : 'b',
u'\u0412' : 'V', u'\u0432' : 'v',
u'\u0413' : 'G', u'\u0433' : 'g',
u'\u0414' : 'D', u'\u0434' : 'd',
u'\u0415' : 'E', u'\u0435' : 'e',
u'\u0401' : 'Yo', u'\u0451' : 'yo',
u'\u0416' : 'Zh', u'\u0436' : 'zh',
@xfenix
xfenix / csv_output.php
Created October 4, 2012 12:08
CSV cross-platform generation (utf-16le)
header("Cache-Control: must-revalidate");
header("Pragma: must-revalidate");
header("Content-type: application/vnd.ms-excel; charset=URF-16LE");
header("Content-disposition: attachment; filename=file.csv");
echo chr( 0xFF ) . chr( 0xFE ) . mb_convert_encoding( $content, 'UTF-16LE', 'UTF-8' );