Skip to content

Instantly share code, notes, and snippets.

View danielbwa's full-sized avatar

Daniel Bakker danielbwa

View GitHub Profile
@brenogazzola
brenogazzola / custom_active_storage_urls.rb
Last active October 17, 2022 15:34
Creating a custom ActiveStorage controller to generate "pretty urls" or help migration from another lib
# This demonstrates how we create a SEO friendly url for the previews of the artworks we sell.
#
# This is the URL we want:
# https://festalab.com.br/image/invitation/birthday/carnival.jpg
#
# First, the route.
#
# "model" is the name of the active storage model that has the preview.
# "classification" and "identifier" are together a unique key for the records.
@geraldvillorente
geraldvillorente / import.md
Created June 14, 2017 05:03
How to import database in MySQL in Docker?

This is a simple way of importing MySQL database in Docker.

  1. In you Dockerfile you must have a shared folder. Shared folder is a directory in your host machine that is mounted to Docker instance.

  2. Put the exported sql file in the shared folder.

  3. Login to your Docker instance via docker exec -it DOCKER_CONTAINER_ID bin/bash.

  4. Login to MySQL via mysql -u USERNAME -p.

@jbenet
jbenet / simple-git-branching-model.md
Last active April 9, 2024 03:31
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@fred
fred / active_admin.rb
Created May 2, 2012 08:10
extend active admin to prettier boolean values
# It extends activeadmin to show pretty boolean values
#
# config/initializers/active_admin.rb
module ActiveAdmin
module Views
class TableFor
def bool_column(attribute)
column(attribute){ |model| model[attribute] ? '✔'.html_safe : '✗'.html_safe }
end
@cosenary
cosenary / success.php
Last active July 30, 2018 07:43
Instagram PHP API - How to get the most recent media published by an Instagram user.
<?php
/**
* Instagram PHP API
* Example for using the getUserMedia() method
*
* @link https://github.com/cosenary/Instagram-PHP-API
* @author Christian Metz
* @since 31.01.2012
*/
@jwo
jwo / registrations_controller.rb
Created September 30, 2011 23:11
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@yagitoshiro
yagitoshiro / push_notifications.js
Last active August 13, 2016 17:29
apple push notification sample (Titanium Mobile)
//////////////////////push_notifications.js///////////////////////
var apns = function(){
var pref = require('preferences').preferences;
Titanium.Network.registerForPushNotifications({
types: [
Titanium.Network.NOTIFICATION_TYPE_BADGE,
Titanium.Network.NOTIFICATION_TYPE_ALERT
],
success:function(e)