Skip to content

Instantly share code, notes, and snippets.

View zulhfreelancer's full-sized avatar

Zulhilmi Zainudin zulhfreelancer

View GitHub Profile
@zulhfreelancer
zulhfreelancer / rails_check_day_and_noon.md
Created October 5, 2015 03:09
Rails: check day and noon
def a
  if Time.zone.now.monday?
    if Time.zone.now == Time.zone.now.noon
      puts "this is the right time"
    else
      puts "sorry, this is not the time"
    end
  else
 puts "sorry, not today man"
@zulhfreelancer
zulhfreelancer / heroku.md
Created October 5, 2015 06:22
Push from local non-master branch to Heroku master

git push heroku localbranch:master

@zulhfreelancer
zulhfreelancer / challenge.md
Last active November 10, 2015 04:27
FizzBuzz Challenge Solution (Javascript) - Demo: https://jsfiddle.net/kLdwncym/

@zulhfreelancer
zulhfreelancer / function_in_function.md
Last active November 10, 2015 07:54
How to call a function inside a function?

You should put your function inside a variable so that you can access it like object.

var toggleVis = (function() {
    return {
        showSomething : function () {
          console.log("showSomething");
        },

 hideSomething : function () {
@zulhfreelancer
zulhfreelancer / rails_where.md
Last active November 13, 2015 06:25
Rails where date syntax

ModelName.where("date > ?", "2015-11-22")

@zulhfreelancer
zulhfreelancer / poslaju_api_v2.md
Last active April 23, 2021 17:25
Poslaju API V2 Endpoint & Result Example

Disclaimer

I'm not working for Poslaju and I don't provide support for this.


Endpoint:

http://api.pos.com.my/v2TrackNTraceWebApi/api/Details/[TRACKING_NUMBER]?callback=result&sKey=7oHHMvxM0&_=1447773442872

@zulhfreelancer
zulhfreelancer / add_jquery_plugin.md
Last active March 28, 2023 07:55
How to add jQuery plugin inside Rails project?

Step 1: Download the JS file (example: abc.min.js).

Step 2: Save it inside vendor/assets/javascripts/ folder.

Step 3: To use it inside specific view, put this tag <%= javascript_include_tag 'abc.min' %> inside the view (*.html.erb)

  • And put this inside config/initializers/assets.rb file: Rails.application.config.assets.precompile += %w( abc.min.js )

Step 4: To use it globally inside the Rails app, put this inside application.js file:

@zulhfreelancer
zulhfreelancer / controller.md
Last active November 24, 2015 05:06
Respond to specific JS file in Rails controller
respond_to do |format|
    format.js {
        render  :template => "path/to/file.js.erb",
                :layout => false
    }
end

Example:

@zulhfreelancer
zulhfreelancer / delete_all_git_branches.md
Last active December 2, 2015 07:37
How to delete all local git merged branches at once except master branch?
  1. git checkout master
  2. git branch --merged master | grep -v master | xargs git branch -d
  3. Done
@zulhfreelancer
zulhfreelancer / subl_shortcut_for_zsh.md
Created December 3, 2015 14:57
How to make `subl` shortcut in zsh to open Sublime Text 2?
  1. cd /usr/local/bin

  2. ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" subl