Skip to content

Instantly share code, notes, and snippets.

@mbuyco
mbuyco / related-tables.sql
Last active October 5, 2022 06:48
Given a database name and table name, find all tables which have a foreign key constraint with the given table.
@mbuyco
mbuyco / index.html
Last active December 3, 2018 08:57
NEooKQ
<html>
<head>
<style type="text/css">
body {
font-family: Arial, Helvetica;
}
#body {
width: 100%;
height: 100%;
<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
@mbuyco
mbuyco / readme.md
Last active May 22, 2021 20:11
CodeIgniter Password Hash Library installation tutorial by mac_devin

DISCLAIMER: I do not own any of the source codes provided below. This is only a tutorial on how to install CodeIgniter-Phpass-Library in your CodeIgniter applications. If you want to see the original tutorial, please go to this link: https://github.com/jenssegers/CodeIgniter-Phpass-Library

CodeIgniter Password Hash Library

phpass is a portable password hashing framework for use in PHP applications. The preferred (most secure) hashing method supported by phpass is the OpenBSD-style bcrypt (known in PHP as CRYPT_BLOWFISH), with a fallback to BSDI-style extended DES-based hashes (known in PHP as CRYPT_EXT_DES), and a last resort fallback to an MD5-based variable iteration count password hashing method implemented in phpass itself.

Installation

  1. Download this .zip file: https://github.com/jenssegers/CodeIgniter-Phpass-Library/archive/master.zip
  2. From the downloaded files, copy the libraries and vendor folder into your CodeIgniter application folder.
def create
@product = Product.new(params[:product])
if @product.save
redirect_to user_url # user_url requires an ID
# redirect_to users_url -- use this to go to the users/index
else
render action: "new"
end
end
@mbuyco
mbuyco / gist:5906531
Last active December 19, 2015 05:49
This is how you append html codes using JQuery.
$(document).ready(function()
{
$("#append_form").submit(function() {
// The \n below is for new line in JavaScript
var append_texts = "<div>\n"+
$("#append_text_1").val() +" "+ $("#append_text_1").val() +"\n"+
"</div>";
$("#append_area").append(append_texts);
});
$(document).ready(function(){
$('#images_list').sortable().on('click', 'img', function(event) {
var target = $(this), src = target.attr('src');
target.attr('src', /cat/.test(src) ? src.replace('cat', 'ninja') : src.replace('ninja', 'cat'));
});
/* line 1: sortable() is for the pictures to be dragged from one position to the other; and a trigger when the image is clicked
line 2: assigning values to variables target and src to make line 3 less confusing and short
line 3: short cut form of if/else statement
considering that the image file names used is cat1.jpg,cat2.jpg.. and respective partner picture file names are ninja1.jpg, ninja2.jpg..
when the image is clicked...