Skip to content

Instantly share code, notes, and snippets.

@agarciadelrio
agarciadelrio / php-simple-router.php
Last active June 30, 2022 09:31
PHP Simple router
<?php
$ROUTES = [
'GET' => [
'home' => 'Home::index',
'ping' => 'Session::getPing',
],
'POST' => [
'ping' => 'Session::postPing',
]
@agarciadelrio
agarciadelrio / ko_bindings.js
Last active August 8, 2022 07:28
KnockoutJS Extenders Collection
/* <div data-bind="blockUI: IsLoading">...</div> */
ko.bindingHandlers.blockUI = {
update: function (element, valueAccessor, allBindingsAccessor) {
var value = ko.utils.unwrapObservable(valueAccessor());
if (value)
$(element).block();
else
$(element).unblock();
}
};
@agarciadelrio
agarciadelrio / css-heading-buttons-3d-with-some-relief.markdown
Created August 9, 2019 21:13
CSS Heading Buttons 3D with some relief
@agarciadelrio
agarciadelrio / .bash_aliases
Last active March 20, 2019 18:57
My current bash profile
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
#alias ll='ls -alF'
alias ls='ls -1G'
alias ll='ls -lF'
alias la='ls -A'
alias l='ls -CF'
alias ltr="ls -R | grep \":$\" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'"
@agarciadelrio
agarciadelrio / messages_after_install.txt
Created August 13, 2016 12:29
Messages after install
~ brew install mongodb
=> Caveats
To have launchd start mongodb now and restart at login:
brew services start mongodb
Or, if you don't want/need a background service you can just run:
mongod --config /usr/local/etc/mongod.conf
==> Summary
🍺 /usr/local/Cellar/mongodb/3.2.8
class Item:
def __init__(self, **args):
self.__dict__.update(args)
i = Item(foo=1, bar=2)
print i.bar
# 2
print i.foo
# 1
@agarciadelrio
agarciadelrio / active_admin.js
Created April 17, 2012 20:30
Getting active_admin panels become collapsable with non-intrusive javascript with jquery
//....add this in app/assets/javascript/active_admin.js
$(function(){
// CONFIGURE PANELS COLLAPSER
$(".panel[data-panel]").each(function(){
var $this = $(this);
var $a = $("<a href='javascript:void(null)'>").on("click",function(event){
$(this).closest(".panel").find(".panel_contents").each(function(){
$(this).slideToggle();
});
$(this).closest("h3").each(function(){
@agarciadelrio
agarciadelrio / active_admin.rb
Created March 13, 2012 19:30
activeadmin has_many new model label button and I18n
# config/initializer/active_admin.rb
ActiveAdmin.setup do |config|
# == Site Title
#
# Set the title that is displayed on the main layout
# for each of the active admin pages.
...
end
ActiveAdmin::FormBuilder.class_eval do