Skip to content

Instantly share code, notes, and snippets.

View barek2k2's full-sized avatar

Abdul Barek barek2k2

  • Right Codes Solution
  • Dhaka, Bangladesh
View GitHub Profile
I, [2014-03-13T20:57:38.209767 #12920] INFO -- : Not reporting to Code Climate because ENV['CODECLIMATE_REPO_TOKEN'] is not set.
"NoMethodError at /request_orders/2/company_fields\n=================================================\n\n> undefined method `model_name' for NilClass:Class\n\napp/views/request_orders/company_fields.html.haml, line 3\n---------------------------------------------------------\n\n``` ruby\n 1 What name do you want for your company?\n 2 \n> 3 = form_for @request_order do |f|\n 4 - @company_fields.each do |field|\n 5 - instance_value = @request_order.company.get_field_instace_with_name(field.master_field.field_name)\n 6 = label_tag \"field_\#{field.master_field.field_name}\", field.master_field.name\n 7 = field.master_field.display(instance_value, { name: \"request_order[company][\#{field.master_field.field_name}]\"})\n 8 \n```\n\nApp backtrace\n-------------\n\n - app/views/request_orders/company_fields.html.haml:3:in `_app_views_re
@barek2k2
barek2k2 / gist:8280865
Created January 6, 2014 10:28
Gridler curl request server log
Started POST "/email_processor" for 127.0.0.1 at 2014-01-06 16:24:56 +0600
Processing by Griddler::EmailsController#create as JSON
Parameters: {"headers"=>"Received: by 127.0.0.1 with SMTP...", "to"=>"thoughtbot <[email protected]>", "from"=>"John Doe <[email protected]>", "subject"=>"Hello there", "text"=>"hola hola hola", "html"=>"<p>this is an email message</p>", "SPF"=>"pass", "email"=>{"headers"=>"Received: by 127.0.0.1 with SMTP...", "to"=>"thoughtbot <[email protected]>", "from"=>"John Doe <[email protected]>", "subject"=>"Hello there", "text"=>"hola hola hola", "html"=>"<p>this is an email message</p>", "SPF"=>"pass"}}
(0.1ms) BEGIN
SQL (110.5ms) INSERT INTO `incoming_emails` (`body`, `created_at`, `from`, `status`, `subject`, `updated_at`) VALUES ('hola hola hola', '2014-01-06 10:24:56', '[email protected]', 'PENDING', 'Hello there', '2014-01-06 10:24:56')
(3.0ms) COMMIT
(0.2ms) BEGIN
(0.2ms) COMMIT
Completed 200 OK in 226ms (ActiveRecord: 129.3ms)
@barek2k2
barek2k2 / gist:7624209
Created November 24, 2013 07:01
sample of OIT_item.txt
"OIT",513099,1,110202,1,�1.69,�0.00,0,�0.31,�0.00,1,290,12,2,11026,0,0,0,0,2
"OIT",513099,2,110202,1,�1.69,�0.00,0,�0.31,�0.00,1,290,12,2,11026,0,0,0,0,2
"OIT",513099,3,110202,1,�1.69,�0.00,0,�0.31,�0.00,1,290,12,2,11026,0,0,0,0,2
"OIT",513100,1,110007,1,�13.00,�0.00,0,�0.00,�0.00,0,290,10,2,10014,0,0,0,0,2
"OIT",513100,2,110007,1,�13.00,�0.00,0,�0.00,�0.00,0,290,10,2,10014,0,0,0,0,2
"OIT",513100,3,110028,1,�14.00,�0.00,0,�0.00,�0.00,0,290,10,2,10014,0,0,0,0,2
"OIT",513100,4,110038,1,�18.00,�0.00,0,�0.00,�0.00,0,290,10,2,10014,0,0,0,0,2
@barek2k2
barek2k2 / gist:6671483
Created September 23, 2013 14:43
Rails application Code sample
CoursesController:
def index
@remote_ip = request.remote_ip
if params[:query].present?
@courses = Course.sphinx_search(params)
elsif params[:this_week].present?
@courses = Course.this_week.paginate(:page => params[:page], :per_page => 15)
elsif params[:this_month].present?
@courses = Course.this_month.paginate(:page => params[:page], :per_page => 15)
elsif params[:upcoming].present?
@barek2k2
barek2k2 / Most used linux command
Last active July 26, 2023 10:43
Useful linux commands while developing Rails web applications
Copy directory to remote server from remote server
scp -r sourcedir/ [email protected]:/dest/dir/
scp -i /home/barek/Dropbox/clients/Ongoing_Clients/instaprize/rafflehunter.pem [email protected]:/home/ubuntu/rafflehunter_production.dump.gz /home/barek/Dropbox/clients/Ongoing_Clients/instaprize/
Run a scheduled rake task(lets say update sphinx indexing on every 30 min periodically) on Lunux crontab:
# find where is your rake(which rake)
#m h dom mon dow user command
*/30 * * * * root /bin/bash -l -c 'searchd --stop -c /var/rails/project/current/config sudo dd if=/dev/zero of=/swapfile bs=1024 count=256k sudo dd if=/dev/zero of=/swapfile bs=1024 count=256k sudo dd if=/dev/zero of=/swapfile bs=1024 count=256k/production.sphinx.conf && cd /var/rails/project/current && RAILS_ENV=production /usr/local/bin/rake ts:rebuild && chmod -R 777 tmp/'
@barek2k2
barek2k2 / gist:5926457
Last active December 19, 2015 08:29
All meta tags for twitter
Home page
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@pazienti">
<meta name="twitter:title" content="Pazienti.it - Mai stati meglio">
<meta name="twitter:description" content="Trova un medico e prenota una visita. Invia una domanda allo specialista, oppure consulta subito migliaia di contenuti di salute">
<meta name="twitter:creator" content="@pazienti">
/contenuti page
@barek2k2
barek2k2 / gist:5918867
Created July 3, 2013 14:55
Question gist for twitter meta tags
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@pazienti">
<meta name="twitter:title" content="Cos&#x27;è l&#x27;esame del carico glicemico o curva glicemica?">
<meta name="twitter:description" content="Cos&#x27;è l&#x27;esame del carico glicemico o curva glicemica?">
<meta name="twitter:creator" content="@pazienti">
@barek2k2
barek2k2 / gist:5918661
Created July 3, 2013 14:45
Twitter meta tags
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@pazienti">
<meta name="twitter:title" content="Dr. Linnea Passaler">
<meta name="twitter:description" content="Mi occupo di implantologia e parodontologia: inserimento di impianti quando i denti non ci sono più e malattie delle gengive (parodontite, piorrea)">
<meta name="twitter:creator" content="@pazienti">
<meta name="twitter:image:src" content="http://localhost:3000/system/doctor_profiles/avatars/000/000/124/medium/dr-linnea-passaler.jpg?1354807780">
def self.update_profile(user)
begin
social_media_info = user.social_media_info
if social_media_info.present?
social_media_info = JSON.parse(social_media_info.information)
raw_info = social_media_info['extra']['raw_info']
social_media_info = social_media_info['info']
if raw_info['gender'] == 'male'
sex = 'm'
elsif raw_info['gender'] == 'female'
@barek2k2
barek2k2 / gist:5626515
Last active December 17, 2015 14:39
angular with coffee
if $scope.session.current.doctor_profile.is_active
$http.get("/api/v1/users/0/assigned_questions").success(
(r)->
newr = []
for e in r
e.replying = false
e.autoAssigned = false
newr.push e
$http.get("/api/v1/auto_assigned_questions.json").success(
(resp)->