Skip to content

Instantly share code, notes, and snippets.

View acrogenesis's full-sized avatar
🤖
Beep Boop

Adrian Rangel acrogenesis

🤖
Beep Boop
View GitHub Profile
@acrogenesis
acrogenesis / 0_reuse_code.js
Created January 30, 2014 21:14
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@acrogenesis
acrogenesis / getWeather.sh
Last active August 29, 2015 13:55
How to bypass api restrictions
#!/bin/bash
cd /home/user/pathto/weatherapi
wget -O http://api.wunderground.com/api/heregoeskey/forecast/lang:SP/q/Mexico/Monterrey.json
@acrogenesis
acrogenesis / application_helper.rb
Created January 6, 2015 16:44
Foundation display_flash_messages, supports single and array flash messages
module ApplicationHelper
DEFAULT_KEY_MATCHING = {
alert: :alert,
notice: :success,
info: :standard,
secondary: :secondary,
success: :success,
error: :alert,
warning: :warning
}
@acrogenesis
acrogenesis / timestamp_client.html
Last active August 29, 2015 14:15
Returns timestamp
<html>
<head>
<title>Timestamp</title>
</head>
<script>
var myTimer;
function getTime(){
var xmlhttp;
var span;
if (window.XMLHttpRequest)
@acrogenesis
acrogenesis / toMySqlDate.js
Last active August 29, 2015 14:16
javascript Date toMySqlDate
d = new Date(); // => Thu Feb 26 2015 22:16:14 GMT-0600 (CST)
d.toMySQLDateTime(); // => 2015-02-26 22:16:14
Date.prototype.toMySQLDateTime = function () {
function addZ(n) {
return (n<10? '0' : '') + n;
}
return this.getFullYear() + '-' +
addZ(this.getMonth() + 1) + '-' +
addZ(this.getDate()) + ' ' +
@acrogenesis
acrogenesis / foundation_will_paginate
Created September 27, 2013 17:17
Foundation Will_paginate
module ApplicationHelper
class FoundationLinkRenderer < ::WillPaginate::ActionView::LinkRenderer
protected
def html_container(html)
tag(:ul, html, container_attributes)
end
def page_number(page)
tag :li, link(page, page, :rel => rel_value(page)), :class => ('current' if page == current_page)
@acrogenesis
acrogenesis / Dropbox Duplicates
Created December 21, 2013 18:46
Remove Dropbox Duplicates
find -L ~/Dropbox -name "*conflicted copy*" -exec rm {} \;
@acrogenesis
acrogenesis / application_helper.rb
Last active January 2, 2016 01:39
Railscasts Search, Sort, Paginate, AJAX with Bootstrap 2
module ApplicationHelper
def sortable(column, title = nil)
title ||= column.titleize
css_class = column == sort_column ? "current #{sort_direction}" : nil
direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc"
link_to (css_class ? title + direction_icon(direction) : title).html_safe, params.merge(:sort => column, :direction => direction, :page => nil), {:class => css_class}
end
private
@acrogenesis
acrogenesis / hacks htaccess
Last active January 3, 2016 08:45
.htaccess hacks
Well i didn't see any thread about this so let's start one :DRINK:
Specify the Directory Index:
DirectoryIndex newindex.html
Specify 404 error:
ErrorDocument 404 /404error.html
Redirect 301
Redirect 301 /old.html /new.html
@acrogenesis
acrogenesis / gulpfile.js
Created June 21, 2017 16:02
BrowserSync with rails/gulp
gulp.task('server', function() {
browserSync.init({
proxy: {
target: 'localhost:3000',
reqHeaders: function () {
return { host: 'localhost:8000' };
}
},
port: 8000,
open: true,