Skip to content

Instantly share code, notes, and snippets.

View gerasimua's full-sized avatar
💭
Reactive waiting

Alexander gerasimua

💭
Reactive waiting
View GitHub Profile
@font-face {
font-family: 'Roboto Slab';
src: url("/fonts/googlefonts/RobotoSlab-Bold.ttf");
font-weight: 700;
}
@font-face {
font-family: 'Roboto Slab';
src: url("/fonts/googlefonts/RobotoSlab-Regular.ttf");
font-weight: 400;
}
@gerasimua
gerasimua / style.css
Created February 28, 2016 07:52
IFrame full width
.video-wrapper {
position: relative;
width: 100%;
height: 0;
padding-bottom: 56.25%;
border-radius: 15px;
overflow: hidden;
}
/*class on iframe*/
$body.on('input', '#cvv', function(){
$('#cvv-fake').val(new Array(this.value.length + 1).join('*'));
});
<div class="form-group relative">
<label for="cvv" class="sr-only">CVV</label>
<input type="cvv" id="cvv-fake" class="form-control" name="cvv"
autocomplete="off" placeholder="CVV" title="Card CVV (XXX)"
maxlength="3" value="" tabindex="-1"/>
<input data-bind="value: cvv" type="cvv" id="cvv" class="form-control" name="cvv"
@gerasimua
gerasimua / some.sql
Created October 3, 2015 02:59
On duplicate update all values
INSERT INTO sessions (user_id, token, expires, session_data)
VALUES (?, ?, FROM_UNIXTIME(?), ?)
ON DUPLICATE KEY UPDATE user_id=VALUES(user_id), expires=VALUES(expires), session_data=VALUES(session_data);
@gerasimua
gerasimua / gist:4945c311a5bd83ea89df
Last active October 2, 2015 15:37
Some example of custom message on HTML5 validation error
<input type="text" class="form-control input-lg verify-code-field" data-bind="value: verifyCode"
required pattern="\d{4}" oninvalid="setCustomValidity('Please type 4 digit code')" onchange="try{setCustomValidity('')}catch(e){}"
placeholder="Enter your 4 digit code to claim"/>
@gerasimua
gerasimua / controller.js
Created July 30, 2015 00:14
Angular phone number helper
<input type="text" ng-model="user.phone" name="phone" ng-change="numberHelper()" ng-model-options="{allowInvalid:true}" ng-pattern="/^\+\d-\d{3}-\d{3}-\d{4}$/"/>
function numberHelper(){
var phone = $scope.user.phone;
var formattedPhone = phone;
if(phone && !/^\+\d-\d{3}-\d{3}-\d{4}$/.test(phone)){
phone = phone.replace(/[+-]/g, '');
phone = '+' + phone.substr(0, 1)
+ (phone[1] ? '-' : '') + phone.substr(1, 3)
+ (phone[4] ? '-' : '') + phone.substr(4, 3)
@gerasimua
gerasimua / gist:08d823c5016e25ea9a54
Created July 15, 2015 13:29
Content editable remove unnecessary tags with content and all html tags on paste
$('[contenteditable]').on('paste',function(e) {
e.preventDefault();
var text = (e.originalEvent || e).clipboardData.getData('text/html');
var $result = $('<div></div>').append($(text));
// remove unnecesary tags (if paste from word)
$result.children('style').remove();
$result.children('meta').remove();
@gerasimua
gerasimua / gist:347f1edc757d49e3913c
Created March 31, 2015 00:35
Early click - click that happens before model changed on the checkbox and can prevent change of it
.directive('earlyClick', function() {
return {
require: '?ngModel',
link: {
pre: function(scope, iElement, iAttrs, ctrl)
{
ctrl = null;
if (ctrl) {
//First way: reset the state inside a parser
ctrl.$parsers.push(function(val) {
@gerasimua
gerasimua / gist:6a19751e6ac5c42bb06f
Created March 21, 2015 16:15
Easiest way to clone js objects without pointers
function clone(object){
var copy = JSON.stringify(object);
return JSON.parse(copy);
}
@gerasimua
gerasimua / gist:a4d73b83c122770de980
Created February 3, 2015 11:37
Get IP with proxies
<?php
public function getIp()
{
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$proxies = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$proxies = array_reverse($proxies);
foreach ($proxies as $proxy) {
if ($this->isPrivateIp(trim($proxy))) {
return $this->isPrivateIp(trim($proxy));