Skip to content

Instantly share code, notes, and snippets.

@kalinchernev
kalinchernev / search.html
Created July 21, 2014 13:23
Search form
<?php
/*
* Available variables
* $query array current query from the URL
*/
?>
<?php // dpm($query); ?>
<div id="search-products">
<h2><?php echo t("Rechercher un produit");?></h2>
<form method="GET" id="search-form" action="catalog-search">
@kalinchernev
kalinchernev / rotate-screen.sh
Last active February 1, 2021 20:22 — forked from rubo77/rotate-screen.sh
Bind to a key to rotate the screen of a convertible laptop
#!/bin/bash
# This script rotates the screen and touchscreen input 90 degrees each time it is called,
# also disables the touchpad, and enables the virtual keyboard accordingly
# by Ruben Barkow: https://gist.github.com/rubo77/daa262e0229f6e398766
#### configuration
# find your Touchscreen and Touchpad device with `xinput`
TouchscreenDevice='Wacom ISDv4 E6 Finger touch'
TouchpadDevice='SynPS/2 Synaptics TouchPad'
@kalinchernev
kalinchernev / countries
Created October 6, 2014 09:42
Plain text list of countries
Afghanistan
Albania
Algeria
Andorra
Angola
Antigua & Deps
Argentina
Armenia
Australia
Austria
@kalinchernev
kalinchernev / image_error.js
Created October 21, 2014 11:54
replacing broken images with existing image
$(document).ready(function(){
$('img').error(function(){
$(this).attr('src', 'http://mysite/myimage.jpg');
});
});
@kalinchernev
kalinchernev / noselect.css
Created October 23, 2014 12:11
cross-browser way to disable highlighting selection
.noselect {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@kalinchernev
kalinchernev / font-resizor.js
Created October 23, 2014 12:13
Resizor of font-size in a given div container
var zoomText = function (change) {
var fontSize, fonts, container;
container = $("#block-system-main");
fontSize = Math.floor(parseFloat(container.css('font-size')) / 16);
fonts = ["1em", "1.2em", "1.4em"];
if (change === -1 & fontSize > 0) {
fontSize--;
}
@kalinchernev
kalinchernev / angular-time.html
Created November 13, 2014 11:10
Angular clock
<!doctype html>
<html ng-app="Time">
<head>
<title>Time</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
</head>
<body>
<div ng-controller="MyController">
<h1>{{ clock | date : 'medium' }}</h1>
</div>
@kalinchernev
kalinchernev / domain-replace.js
Created November 19, 2014 10:10
Function to replace development and production urls
// development is a string containing the domain base of the dev site
// production is a string containing the domain base of the production site
function replaceDomains(development,production){
var links = jQuery("a");
for (var i = 0; i < links.length; i++) {
var href = jQuery(links[i]).attr("href");
if ((href !== undefined) && (href.indexOf(production) > -1)) {
href = href.replace(production, development);
jQuery(links[i]).attr("href", href);
}
@kalinchernev
kalinchernev / char-reverse.py
Created November 25, 2014 21:16
Reverse chars of a string
def reverse(string):
buffer = []
for char in string:
buffer.insert(0, char)
reversed = ''.join(buffer)
return reversed
@kalinchernev
kalinchernev / center-method.js
Created December 11, 2014 12:47
jQuery method to center an element on the window
jQuery.fn.center = function () {
this.css("position","absolute");
this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) + $(window).scrollTop()) + "px");
this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) +
$(window).scrollLeft()) + "px");
return this;
}