Skip to content

Instantly share code, notes, and snippets.

View beshur's full-sized avatar

Alex Buznik beshur

View GitHub Profile
@beshur
beshur / countdownize.js
Created December 9, 2013 14:05
jQuery Simple minutes countdown timer
// jQuery Simple minutes countdown timer
// https://gist.github.com/beshur/7872704
// @beshur
$.fn.countdownize = function() {
if (typeof window.page_var == "undefined") window.page_var = {};
this.each(function(i) {
var obj = $(this);
// assumes integer seconds are here
@beshur
beshur / inputNumberize.js
Created December 13, 2013 14:46
simple jQuery number input imitator
// simple jQuery input[type='number'] imitator
// with callback on number change
//
// supposed markup:
// <div class="elemnt">
// <input type="text" class="target" />
// <span class="arr more"></span>
// <span class="arr less"></span>
// </div>
$.fn.inputNumberize = function(options) {
@beshur
beshur / helper.js
Created January 14, 2014 10:56
meteor Handlebars helper
Handlebars.registerHelper("_i18n", function (string, content) {
if (!string) return;
var t = __(string, {message: content});
return t;
});
@beshur
beshur / resize.js
Created February 3, 2014 10:40
javascript jQueryUI Resizable window resize bug fix (jQuery)
// fix jqueryui resizable bug:
//
// jqueryui resizable on 'resize' event invokes
// window.resize event, which maybe unwanted behaviour sometimes
//
window.onresize = function(event) {
if (typeof event.target.getAttribute === 'function')
return;
};
@beshur
beshur / al.php
Created March 19, 2014 09:57
php Yii attributeLabels example
<?php
class Profile extends CActiveRecord
{
public function attributeLabels()
{
return array(
'id' => Yii::t('model', 118),
'from' => Yii::t('model', 119),
'email' => Yii::t('model', 120),
'user_id' => Yii::t('model', 121),
@beshur
beshur / gist:9951830
Created April 3, 2014 10:00
laravel error tmp
<?php
App::error(function(Exception $exception, $code)
{
Log::error($exception);
// Save data to the database
$getUser = '';
// ....
@beshur
beshur / httpd-vhosts.conf
Created May 27, 2014 12:01
temp virtual host for family.beetroot
# Virtual Hosts
#
<VirtualHost *:80>
DocumentRoot "c:\wamp\www\family-beetroot"
ServerName family_br.loc
</VirtualHost>
@beshur
beshur / checkboxize.css
Last active August 29, 2015 14:01
jQuery Simple checkbox javascript after styling
.e_checkbox,
.e_radiobox {
position: relative;
display: inline-block;
width: 17px;
height: 17px;
margin-right: 5px;
}
<?php
/**
* Define type of server
*
* Depending on the type other stuff can be configured
* Note: Define them all, don't skip one if other is already defined
*/
define( 'DB_CREDENTIALS_PATH', dirname( ABSPATH ) ); // cache it for multiple use
@beshur
beshur / route.js
Last active August 21, 2019 04:02 — forked from cultofmetatron/gist:5349630
Javascript Node.js Express Login route with ajax responses
app.post('/login', function(req, res) {
console.log(res);
passport.authenticate('local', function(err, user, params) {
if (req.xhr) {
//thanks @jkevinburton
if (err) { return res.json({ error: err.message }); }
// e.g. in auth.js:
// if (!user.emailVerified) { return done(null, false, { message: 'Email is not verified. Please check your email for the link.' }); }
if (!user && params) { return res.json({error : params.error}); }