This file contains hidden or 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 declOfNum(number, titles) { | |
| cases = [2, 0, 1, 1, 1, 2]; | |
| return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ]; | |
| } | |
| use: | |
| declOfNum(count, ['товар', 'товара', 'товаров']); |
This file contains hidden or 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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
This file contains hidden or 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 | |
| source=$(xsel -o | sed "s/["'<>]//g") | |
| trans="$(wget -U "Mozilla/5.0" -qO - "http://translate.google.com/translate_a/t?client=t&text=${source}&sl=auto&tl=$1" | sed 's/[[["//' | cut -d " -f 1)" | |
| url=`echo "$trans" | xclip -filter -selection clipboard` | |
| notify-send -t 2500 "$source" "$trans" |
This file contains hidden or 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
| var Anchors = document.getElementsByTagName("a"); | |
| for (var i = 0; i < Anchors.length ; i++) { | |
| Anchors[i].addEventListener("click", | |
| function (event) { | |
| event.preventDefault(); | |
| if (confirm('Are you sure?')) { | |
| window.location = this.href; | |
| } | |
| }, |
This file contains hidden or 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
| SELECT *, table1.id AS newFieldName FROM table |
This file contains hidden or 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 xmail( $from, $to, $subj, $text, $filename) { | |
| $f = fopen($filename,"rb"); | |
| $un = strtoupper(uniqid(time())); | |
| $head = "From: $from\n"; | |
| $head .= "To: $to\n"; | |
| $head .= "Subject: $subj\n"; | |
| $head .= "X-Mailer: PHPMail Tool\n"; | |
| $head .= "Reply-To: $from\n"; | |
| $head .= "Mime-Version: 1.0\n"; | |
| $head .= "Content-Type:multipart/mixed;"; |
This file contains hidden or 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
| font-family: Arial, Helvetica, sans-serif; | |
| font-family: 'Arial Black', Gadget, sans-serif; | |
| font-family: 'Bookman Old Style', serif; | |
| font-family: 'Comic Sans MS', cursive; | |
| font-family: Courier, monospace; | |
| font-family: 'Courier New', Courier, monospace; | |
| font-family: Garamond, serif; | |
| font-family: Georgia, serif; | |
| font-family: Impact, Charcoal, sans-serif; | |
| font-family: 'Lucida Console', Monaco, monospace; |
This file contains hidden or 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
| var check_if_ios = function() { | |
| var is_ios = /iphone|ipad|ipod/i.test(navigator.userAgent.toLowerCase()); | |
| if (is_ios) { | |
| alert("iOS"); | |
| } else { | |
| alert("not iOS"); | |
| } | |
| } |
This file contains hidden or 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 () { | |
| var left_links = document.getElementById("menu").getElementsByTagName('a'); | |
| var current_url = document.location; | |
| for (var i = 0; i < left_links.length; i++) { | |
| if (current_url.pathname == left_links[i].pathname && current_url.host == left_links[i].host ) { | |
| left_links[i].className += ' active'; | |
| } | |
| } | |
| })(); |
This file contains hidden or 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
| var add_class = function(element, classname) { | |
| var class_name = element.className; | |
| //test for existance | |
| if( class_name.indexOf( classname ) !== -1 ) { | |
| return; | |
| } | |
| //add a space if the element already has class | |
| if( class_name !== '' ) { | |
| classname = ' '+classname; | |
| } |
OlderNewer