Skip to content

Instantly share code, notes, and snippets.

View githubjeka's full-sized avatar
🍪
focusing

Evgeniy Tkachenko githubjeka

🍪
focusing
  • -20.937103644166523, 164.65842641592772
View GitHub Profile
@tom--
tom-- / Random bytes, ints, UUIDs in PHP.md
Last active February 11, 2023 06:14
PHP random bytes, integers and UUIDs

Random bytes, ints, UUIDs in PHP

Simple and safe random getters to copy-paste

string randomBytes( int $length )

int randomInt ( int $min , int $max )

string randomUuid ( void )
<?php
class Foo
{
private $foo;
private $bar;
private $baz;
}
$hydrator = function(array $data) {
@keltstr
keltstr / protected.components.UrlManager.php
Last active April 27, 2016 13:21
File:: protected/components/UrlManager.php::RUSSIAN DESCRIPTION::Расширяет возможности базового класса CUrlManager.Делается проверка запроса Url на обращение к нему по его дубликату с использованием имени файла входного скрипта(обычно index.php).При выявлении дубликата Url делается редирект на оригинальный Url ЛИБО отдает ошибку HTTP 404 (в зави…
<?php
class UrlManager extends CUrlManager{
/**File:: protected/components/UrlManager.php (Yii v1.1.14 compatible . May be less...)
::RUSSIAN DESCRIPTION::
В Yii наши URL по-умолчанию выглядят так http://site.com/index.php?param1=a или http://site.com/index.php/param1/a, но обычно мы хотим избавится от имени входного скрипта(index.php) в URL.
И для этого устанавливаем в настройках параметр 'URLManager'=>array(...,'showScriptName' => false,...), но этот способ работает только для формирования и приема URL(http://site.com/param1/a).
Но по-прежнему позволяет обращаться к нашему адресу по его старому значению http://site.com/index.php/param1/a .
ЭТОТ СКРИПТ закрывает эту маленькую огрешность - т.е. не разрешает обращаться к URL в котором по-прежнему присутствует имя входного скрипта после site.com
<?php
/**
* DuplicateFilter prevents Yii from exposing URLs starting with /index.php/ when showScriptName is false. Such
* URLs are automatically redirected to proper ones.
*
* To use add the following to your controller:
*
* ```php
* public function filters() {
* return array(
@nicolashery
nicolashery / elasticsearch.md
Last active December 30, 2023 19:03
Elasticsearch: updating the mappings and settings of an existing index

Elasticsearch: updating the mappings and settings of an existing index

Note: This was written using elasticsearch 0.9.

Elasticsearch will automatically create an index (with basic settings and mappings) for you if you post a first document:

$ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \
'{
  "_id": 1,
@raveren
raveren / cryptographically_secure_random_strings.php
Last active November 21, 2023 12:35
Generate cryptographically secure random strings. Based on Kohana's Text::random() method and this answer: http://stackoverflow.com/a/13733588/179104
function random_text( $type = 'alnum', $length = 8 )
{
switch ( $type ) {
case 'alnum':
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'alpha':
$pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'hexdec':
@methodofaction
methodofaction / index.html
Created October 3, 2012 02:48
Make an element follow a path
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<style type="text/css">
#line{
width: 100%;
margin: 20px 0;
height: 300px;
background: #eee;
@i-scorpion
i-scorpion / README.txt
Created June 18, 2012 12:24
Twitter bootstrap fixed table header using jQuery
Here is a simple jQuery plugin to make a table header fixed on top when window is scrolled.
Using the code from twitter bootstrap documentation page, this code is customized for table header.
Create the table with following layout -
<table class="table-fixed-header">
<thead class="header">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
@ziadoz
ziadoz / awesome-php.md
Last active April 17, 2024 21:06
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.