Skip to content

Instantly share code, notes, and snippets.

View rdobrynin's full-sized avatar

Roman Dobrynin rdobrynin

View GitHub Profile
@rdobrynin
rdobrynin / gist:9e5543c3e742d3db7717
Created February 18, 2015 09:28
CI Active records JOIN two tables
<?
public function getProjectUsers($pid) {
$data = array();
$query = $this->db->select('*')
->from('projects')
->join('users', 'projects.uid = users.id')
->where('projects.assign', 0)
->where('projects.pid', $pid)
->get();
if ($query->num_rows() > 0)
@rdobrynin
rdobrynin / gist:ea4948ffdcaad78696f2
Created February 24, 2015 09:12
Best helvetica css
body {
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
}
@rdobrynin
rdobrynin / gist:dd9c94087e739fee2e7c
Created February 24, 2015 10:59
ZF media reina image
@mixin image-2x($image, $width, $height) {
@media (min--moz-device-pixel-ratio: 1.3),
(-o-min-device-pixel-ratio: 2.6/2),
(-webkit-min-device-pixel-ratio: 1.3),
(min-device-pixel-ratio: 1.3),
(min-resolution: 1.3dppx) {
/* on retina, use image that's scaled by 2 */
background-image: url($image);
background-size: $width $height;
}
echo "# backbone" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/rdobrynin/backbone.git
git push -u origin master
git remote add origin https://github.com/rdobrynin/backbone.git
git push -u origin master
@rdobrynin
rdobrynin / random_password
Created June 15, 2015 13:15
generate random password
function random_password($length = 8, $allow_uppercase = true, $allow_numbers = true) {
$out = '';
$arr = array();
for($i=97; $i<123; $i++) $arr[] = chr($i);
if ($allow_uppercase) for($i=65; $i<91; $i++) $arr[] = chr($i);
if ($allow_numbers) for($i=0; $i<10; $i++) $arr[] = $i;
shuffle($arr);
for($i=0; $i<$length; $i++)
{
$out .= $arr[mt_rand(0, sizeof($arr)-1)];
@rdobrynin
rdobrynin / gist:a132f2296123ef2e64ac
Created February 16, 2016 13:41
remove validation bubbles
function replaceBubbleFormUI( form ) {
// Suppress the default bubbles
form.addEventListener( "invalid", function( event ) {
event.preventDefault();
}, true );
// Support Safari, iOS Safari, and the Android browser—each of which do not prevent
// form submissions by default
form.addEventListener( "submit", function( event ) {
if ( !this.checkValidity() ) {
<script type="text/javascript">
<!--
function viewport()
{
var e = window
, a = 'inner';
if ( !( 'innerWidth' in window ) )
{
a = 'client';
e = document.documentElement || document.body;
@rdobrynin
rdobrynin / mysql-docker.sh
Created November 13, 2019 13:13 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@rdobrynin
rdobrynin / wpdb-column-examples.php
Created December 20, 2019 09:15 — forked from jeffward3283/wpdb-column-examples.php
WordPress Database Examples
<?php
////////////////////////
# COLUMN EXAMPLES
////////////////////////
////////////////////////
# Add Column (after)
////////////////////////
global $wpdb;