Skip to content

Instantly share code, notes, and snippets.

server {
listen 80;
server_name ~^(www\.)?(?<sname>.+?).local.com$;
root /var/www/$sname/public;
index index.html index.htm index.php;
charset utf-8;
location / {
# Inspired from http://blog.hio.fr/2011/09/17/doctrine2-yaml-mapping-example.html
MyEntity:
type: entity
repositoryClass: MyRepositoryClass
table: my_entity
namedQueries:
all: "SELECT u FROM __CLASS__ u"
# Class-Table-Inheritance
@shmaltorhbooks
shmaltorhbooks / objectByString.js
Last active August 29, 2015 14:21
Access to object members by string path
/**
* @example Object.byString(someObject, 'part1.name')
* @example Object.byString(someObject, 'part2.qty')
* @example Object.byString(someObject, 'part3[0].name')
*
* @param obj {Object}
* @param str {String}
* @returns {*}
*/
Object.byString = function(obj, str) {
@shmaltorhbooks
shmaltorhbooks / reg.php
Created August 27, 2015 09:03
Cut images (with links and without)
$image = "/(<a[^<]+\>[^<]*|)\<img [^<]+\>([^<]*\<\/a\>|)/ism";
@shmaltorhbooks
shmaltorhbooks / covnert_to_utf8.sh
Created August 27, 2015 09:05
convert project files to OTF-8
find . -name "*.jsp" -exec fconv {} \;
SELECT
`sights_lang`.`name`,
`sights_lang`.`address`,
`sights`.`category_id`,
`sights_categories_lang`.`
categoryName`,
`sights`.`latitude`,
`sights`.`longitude`,
`sights`.`sights_id`
FROM `partner_hotels`.`sights_lang`
@shmaltorhbooks
shmaltorhbooks / object.path.js
Created September 14, 2015 08:54
access to object properties by string path
Object.path = Object.byString = function(obj, str, undefined) {
if (str in obj) {
return obj[str];
}
if ((!str.length) || (null === obj)) {
return obj;
}
var a = str.replace(/\[(\w+)\]/g, '.$1').replace(/^\./, '').split('.'); // convert indexes to properties and strip a leading dot
for (var i = 0, n = a.length; i < n; ++i) {
var k = a[i];
@shmaltorhbooks
shmaltorhbooks / RelativeAbsolutePathTransformer.php
Created September 25, 2015 11:32
Convert relative links to absolute path in href/src attributes
preg_replace('/((?:href|src) *= *[\'"](?!(\/\/|#|http|ftp)))/i', '$1' . $this->url, $value)
@shmaltorhbooks
shmaltorhbooks / NumberSystem.kt
Last active February 28, 2025 15:42
convert id between number systems
package org.timeout.app
import java.math.BigInteger
class NumberSystem(val alphabet: String = "0123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ") {
val base = alphabet.length.toBigInteger()
fun encode(input: String): String {
val number = BigInteger(1, input.toByteArray())
val encoded = StringBuilder()
var num = number
@shmaltorhbooks
shmaltorhbooks / delete-old-files.sh
Created February 7, 2017 08:23
Delete files older that 5 days
find /path/to/files* -mtime +5 -exec rm {} \;