Skip to content

Instantly share code, notes, and snippets.

View zulhfreelancer's full-sized avatar

Zulhilmi Zainudin zulhfreelancer

View GitHub Profile
@zulhfreelancer
zulhfreelancer / index.html
Last active August 29, 2015 14:13
Web Hosting Bandwidth Calculator (jQuery) // Demo: http://jsfiddle.net/cydL0hby/4/
<h4>Web Hosting Bandwidth Calculator</h4>
<form>
<input id="avg_page_size" placeholder="Avg page size (MB)" type="text" />
<br/>
<br/>
<input id="avg_daily_visitor" placeholder="Avg daily visitor" type="text" />
<br/>
<br/>
<input id="avg_pages_per_visit" placeholder="Avg pages per visit" type="text" />
@zulhfreelancer
zulhfreelancer / result.php
Last active August 29, 2015 14:13
Share to Facebook with Image + Link to Website
// Demo: http://dontbodoh.com/result.php?char=character1.png <-- char paramater is dynamic based on result, return different image
// Check out line number 11 (image) and 14 (auto refresh)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width; initial-scale=1; minimum-scale=1,maximum-scale=1.0; user-scalable=1;">
<meta property="og:title" content="I have just checked if my mobile plan is the best in town through Don't Bodoh.">
@zulhfreelancer
zulhfreelancer / index.css
Created January 21, 2015 19:01
Show an Input Field Based On Selected Dropdown And Change a Hidden Input Value Based on That Showed Input Content (if empty and if not empty) // Demo: http://jsfiddle.net/tfntj5ds/
#ref {
display:none;
}
@zulhfreelancer
zulhfreelancer / SimpleHTTPServer.md
Last active September 6, 2016 16:39
Start SimpleHTTPServer Using Mac Terminal
cd /path/
python -m SimpleHTTPServer 8000
@zulhfreelancer
zulhfreelancer / connect
Last active August 29, 2015 14:18
Connect to localhost from other devices (on same network) using Anvil for Mac (http://anvilformac.com), Pow & Xip.io
1. Install Anvil for Mac - http://anvilformac.com/
2. Inside Anvil, install Pow (this will launch Terminal)
3. Go your machine System Preference > Network & copy your machine IP address (eg: 192.168.X.XXX)
4. Add a project using Anvil. Project URL will be something like this: project.dev
5. To access the project from other devices, type this URL format: [PROJECT].[IP_ADDRESS].xip.io
Example:
Anvil URL: helloworld.dev (only works in your local development machine)
Localhost URL: helloworld.192.168.X.XXX.xip.io (works on all devices on same network)
1. Install BrowserSync via NPM:
npm install -g browser-sync
2. Using Terminal, cd into project folder:
Example: cd/test
3. Add this kind of script inside HTML files:
Contacts = new Mongo.Collection('contacts');
var checked = [];
if (Meteor.isClient) {
Template.contacts.helpers({
contacts: function(){
var filter = {sort: {}};
var query = Session.get('query');
filter.sort[Session.get('sortfilter')] = 1;
@zulhfreelancer
zulhfreelancer / functions.php
Created June 14, 2015 21:09
Remove Image Sizes Option in WordPress Media Upload Window
// ADD NEW IMAGE SIZE
add_action( 'after_setup_theme', 'baw_theme_setup' );
function baw_theme_setup() {
add_image_size( 'full-post-width', 568 ); // 568 pixels wide (and unlimited height)
}
// REMOVE ALL IMAGE SIZES IN MEDIA UPLOADER WINDOW
function my_custom_image_sizes($sizes) {
unset( $sizes['thumbnail']);
unset( $sizes['medium']);
@zulhfreelancer
zulhfreelancer / paperclip_heroku.md
Last active September 26, 2015 20:37
Rails Paperclip Amazon S3 Heroku Error: We're sorry, but something went wrong.

So today I decided to explore how to use Paperclip + Amazon S3 on Heroku for photo upload process. The process is quite straight forward.

But, I got stucked after I deployed the Rails app into my Heroku account. I got this error:

We're sorry, but something went wrong

It took me hours to find out what's wrong. Finally, I found the solution.

Here's what I've done:

@zulhfreelancer
zulhfreelancer / rails.md
Created October 2, 2015 16:15
Delete all tables data and recreate tables in Rails

You can have finer control with:

rake db:drop:all

And then create the database without running the migrations:

rake db:create:all

Then run all your migrations: