Skip to content

Instantly share code, notes, and snippets.

@atma
atma / backup_project.sh
Created January 8, 2011 06:55
Backup the project into Dropbox dir
#!/bin/bash
PRJ='project'
DROPBOX_DIR='/home/atma/Dropbox/backups'
PROJECT_DIR='/home/atma/www/project'
MHOST='localhost'
MUSER='root'
MPASS='pass'
MBASE='project'
#!/bin/sh
# System + MySQL backup script
# Full backup day - Sun (rest of the day do incremental backup)
# ---------------------------------------------------------------------
### System Setup ###
DIRS="/home/www1 /home/www2"
BACKUP=/tmp/backup.$$
NOW=$(date +"%d-%m-%Y")
INCFILE="/root/tar-inc-backup.dat"
DAY=$(date +"%a")
@atma
atma / plural_ru.php
Created May 16, 2011 04:03
Russian (ukrainian) plural form
<?php
/**
* @param int The number of items
* @param array Three item forms as for 1, 2-4(22,33), 5(66,78) respectively
*/
function plural_form($n, $forms)
{
$n = abs($n) % 100;
$n1 = $n % 10;
if ($n > 10 AND $n < 20) return $forms[2];
@atma
atma / split
Created June 18, 2011 05:59
Splitting an AVI file into smaller parts
mencoder -endpos 01:00:00 -ovc copy -oac copy movie.avi -o first_half.avi
mencoder -ss 01:00:00 -oac copy -ovc copy movie.avi -o second_half.avi
@atma
atma / make_slug.php
Created June 28, 2011 16:00
Make SEO friendly URI. Includes cyrillic subset.
<?php
/**
* Convert a phrase to a SEO friendly uri (slug).
*
* @param string $title Phrase to convert
* @param string $separator Word separator
* @param boolean $ascii_only Transliterate to ASCII?
* @return string
*/
function make_slug($title, $separator = '-', $ascii_only = true) {
@atma
atma / parseUri.js
Created August 5, 2011 04:00
Split URLs in JavaScript
function parseUri (str) {
var o = parseUri.options,
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
uri = {},
i = 14;
while (i--) uri[o.key[i]] = m[i] || "";
uri[o.q.name] = {};
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
@atma
atma / gist:3030909
Created July 2, 2012 03:45
jQuery callback on image load
$("img").one('load', function() {
// do stuff
}).each(function() {
if(this.complete) $(this).load();
});
@reboot ~/node-app-starter.sh >> cron.log 2>&1
@atma
atma / jquery.plugin.js
Created December 2, 2012 18:21
jQuery plugin template
/**
* jquery.plugin.js v1.0.0
* http://github.com/someone/someplugin
*/
;( function( $, window, undefined ) {
'use strict';
var pluginName = 'pluginName',
Plugin = function( options, element ) {
this.$el = $( element );
@atma
atma / basic-tpl.html
Created December 16, 2012 17:34
Basic HTML Page Template
<!doctype html>
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Default Page Title</title>
<link rel="shortcut icon" href="favicon.ico">
<link rel="icon" href="favicon.ico">
<link rel="stylesheet" type="text/css" href="styles.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<!--[if lt IE 9]>