Skip to content

Instantly share code, notes, and snippets.

View Rafailong's full-sized avatar
🤠

ravila Rafailong

🤠
  • Mexico
View GitHub Profile
@Rafailong
Rafailong / script.js
Created January 29, 2014 18:28
Div full Width/Height of viewport with jQuery
// global vars
var winWidth = $(window).width();
var winHeight = $(window).height();
// set initial div height / width
$('div').css({
'width': winWidth,
'height': winHeight,
});
<input type="password" name="pass" id="pass" />
<span id="passstrength"></span>
@Rafailong
Rafailong / script.js
Created January 29, 2014 18:30
Image resizing using jQuery
$(window).bind("load", function() {
// IMAGE RESIZE
$('#product_cat_list img').each(function() {
var maxWidth = 120;
var maxHeight = 120;
var ratio = 0;
var width = $(this).width();
var height = $(this).height();
if(width > maxWidth){
@Rafailong
Rafailong / script.js
Created January 29, 2014 18:31
Automatically load content on scroll
var loading = false;
$(window).scroll(function(){
if((($(window).scrollTop()+$(window).height())+250)>=$(document).height()){
if(!loading){
loading = true;
$('#loadingbar').css("display","block");
$.get("load.php?start="+$('#loaded_max').val(), function(loaded){
$('body').append(loaded);
$('#loaded_max').val(parseInt($('#loaded_max').val())+50);
$('#loadingbar').css("display","none");
@Rafailong
Rafailong / script.js
Created January 29, 2014 18:31
Check if an image is loaded
var imgsrc = 'img/image1.png';
$('<img/>').load(function () {
alert('image loaded');
}).error(function () {
alert('error loading image');
}).attr('src', imgsrc);
@Rafailong
Rafailong / script.js
Created January 29, 2014 18:32
Sort a list alphabetically
$(function() {
$.fn.sortList = function() {
var mylist = $(this);
var listitems = $('li', mylist).get();
listitems.sort(function(a, b) {
var compA = $(a).text().toUpperCase();
var compB = $(b).text().toUpperCase();
return (compA < compB) ? -1 : 1;
});
$.each(listitems, function(i, itm) {
// api/controllers/AuthController.js
var passport = require('passport');
var AuthController = {
login: function (req,res)
{
res.view();
},
using System;
using JabbR.Infrastructure;
using JabbR.Models;
using JabbR.Services;
using Nancy;
using Nancy.Authentication.WorldDomination;
using WorldDomination.Web.Authentication;
namespace JabbR.Nancy
{
@Rafailong
Rafailong / commit-msg.rb
Last active August 29, 2015 14:08
git hook to log time entry in redmine when committing to git, remember to remove the file extension, this MUST be executable
#!/usr/bin/env ruby
require 'rubygems'
require 'rest_client'
require 'json'
url = 'http://yourredmine.com/time_entries.xml'
api_key = "your-redmine-api-key"
activity_id = 'your development activity id'
commitMessage = ARGV[0]
@Rafailong
Rafailong / docker-cleaner.sh
Created October 22, 2015 16:56
Docker remove commands
#! /bin/bash
# remove all stoped container
docker rm $(docker ps -a -q)
# remove tagged images
docker rmi $(docker images -q)
# remove untagged images
docker rmi $(docker images | grep "^<none>" | awk "{print $3}"