Skip to content

Instantly share code, notes, and snippets.

View msadoon's full-sized avatar
:shipit:

Mubarak Sadoon msadoon

:shipit:
  • Toronto, ON
View GitHub Profile
@msadoon
msadoon / tictactoe.rb
Created May 16, 2014 16:09
a little console base tictactoe game I wrote in Ruby.
#init variables
endcase = 0
moveNum = 0
$firstmove = 0
$a,$b,$c,$d,$e,$f,$g,$h,$i = "?", "?", "?", "?", "?", "?", "?", "?", "?"
$v = "?"
def reset(a,b,c,d,e,f,g,h,i)
system('clear')
@msadoon
msadoon / buildings_controller.rb
Last active August 29, 2015 14:02
ajax request success template missing
def getgst
d { 'gets fired' }
s = Building.get_gst_for_building(params[:buildinginfo])
d { s.to_s('F') }
@var = s.to_s('F')
respond_to do |format|
format.html { render :text => @var.html_content }
end
@msadoon
msadoon / ls-la
Created June 25, 2014 17:51
pdftk binary not executing in heroku dynp bash env
~ $ ls
app db heroku_key.txt.pub public ruby-versions.yml
bin Gemfile lib Rakefile test
config Gemfile.lock log README.md tmp
config.ru heroku_key.txt my_log.txt README.rdoc vendor
~ $ cd bin
~/bin $ ls -la
total 21652
drwx------ 3 u22794 22794 4096 2014-06-25 17:49 .
drwx------ 14 u22794 22794 4096 2014-06-25 17:50 ..
@msadoon
msadoon / helps_controller.rb
Last active August 29, 2015 14:03
updating one record in a db
def update
d { @help }
respond_to do |format|
if @help.update(help_params)
format.html { redirect_to @help, notice: 'Help was successfully updated.' }
format.json { render :show, status: :ok, location: @help }
#redirect_to action: "index"
else
format.html { render :edit }
format.json { render json: @help.errors, status: :unprocessable_entity }
@msadoon
msadoon / _form.html.erb
Last active August 29, 2015 14:03
data-confirm update through ajax
<%= submit_tag "Save Changes", :id => "special_message",:class => "btn btn-success navbar-btn", data: { confirm: "" } %>
@msadoon
msadoon / fillable_pdf_form.rb
Created July 2, 2014 00:16
Retrieve template_path for PDFTK
class FillablePdfForm
attr_writer :template_path
attr_reader :attributes
def initialize
fill_out
end
def export(output_file_path=nil, tenantname)
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
helper_method :current_user
before_action :require_login
private
def require_login
@msadoon
msadoon / cheques.js.coffee
Created July 7, 2014 02:11
why won't my coffeescript fire?
$("#cheque_delete").hover ->
window.alert "calls method"
@msadoon
msadoon / angular.js
Last active August 29, 2015 14:08
Unknown provider: $scopeProvider <- $scope <- BugService
<script>
var bugSummaryApp = angular.module('bugSummaryApp', []);
var bugslist = null;
var bugdetails = null;
bugSummaryApp.factory("BugService", ['$http', function(http) {
var webserviceURL = "/invokeWebService?webserviceHost=http://trceit-dev-env.elasticbeanstalk.com:8080&webservicePathURL=/getData";
http.get(webserviceURL).success(function(data) {
@msadoon
msadoon / angular.js
Created October 23, 2014 23:27
angular issues
var bugSummaryApp = angular.module('bugSummaryApp', []);
bugSummaryApp.factory('bugFactory', function($http) {
var webserviceURL = "/invokeWebService?webserviceHost=http://trceit-dev-env.elasticbeanstalk.com:8080&webservicePathURL=/getData";
var bugFactory = {
async: function() {
var promise = $http.get(webserviceURL).then(function (response) {