Skip to content

Instantly share code, notes, and snippets.

View tsega's full-sized avatar
🏰
Working from home

Tsegaselassie Tadesse tsega

🏰
Working from home
View GitHub Profile
# Be sure to restart your web server when you modify this file.
# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
SPREE_GEM_VERSION = '0.9.4' unless defined? SPREE_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
@tsega
tsega / firebug_strophe_log.txt
Created May 2, 2012 06:56
FireFox Log for Strophe.js
OUT: <body rid='2988494751' xmlns='http://jabber.org/protocol/httpbind' sid='f836ece3-cc8f-4c5d-ba1c-ce313d7bb303'/>
jmbu4uc.js (line 104)
IN: <body xmlns='http://jabber.org/protocol/httpbind' sid='f836ece3-cc8f-4c5d-ba1c-ce313d7bb303' xmlns:stream='http://etherx.jabber.org/streams'/>
jmbu4uc.js (line 103)
OUT: <body rid='2988494752' xmlns='http://jabber.org/protocol/httpbind' sid='f836ece3-cc8f-4c5d-ba1c-ce313d7bb303'/>
jmbu4uc.js (line 104)
16, ioError, An error occured preventing completion of the request.
[Break On This Error]
....ie&&P.ua.win?"ActiveX":"PlugIn"),MMdoctitle:V.title.slice(0,47)+" - Flash Playe...
@tsega
tsega / chrome_strophe_muc
Created May 2, 2012 07:19
Chrome Log of MUC Invitation
OUT: <body
rid='3958451097'
xmlns='http://jabber.org/protocol/httpbind'
sid='7a99d0d9-7a7a-4683-9a72-015df3f4a722'>
<presence
xmlns='jabber:client'>
<priority>-1</priority>
</presence>
<presence
to='my-room@conference.localhost/tsegat'
@tsega
tsega / json_parse_error.rb
Created June 15, 2013 12:34
Error when parsing JSON
#JSON::ParserError at /
#757: unexpected token at '<html><head><title>Apache Tomcat/6.0.24 - Error report</title><style><!--H1 {font-#family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-#serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-#color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-#family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-#serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style>
#</head><body><h1>HTTP Status 404 - #/ws/api/store/product/9780942961522,9780942961485,9780942961478,9780942961430,9780942961423,9780942961447,9780942961416,97809429#61515</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b>
#u>/ws/api/store/product/978094296152
// First Define a Strophe Object
var Strobj = {
connection: null,
room: null,
nickname: null,
xmpp_server: "@localhost",
BOSH: "http://localhost:5280/http-bind",
muc: "@conference.localhost",
# Atom Cheatsheet.
# Project Key Bindings.
- 'cmd-shift-p': open the command palette.
- 'cmd-p' or 'cmd-t': open the fuzzy finder to find a file.
- 'cmd-b': look for a file that is already open.
- 'cmd-shift-b': search the list of files modified and untracked in your project repository.
- 'ctrl-0': open and focus the the tree view.
@tsega
tsega / Anonymous Viewers Count
Last active August 29, 2015 14:13
Meteor Sessions
Router.onBeforeAction(function(){
var postSlug = this.params.slug;
var currentPost = Posts.findOne({slug: postSlug});
var anonymousSession = "anonymousViewers_"+currentPost._id;
var anonymousCount = Session.get(anonymousSession);
if(anonymousCount){
Session.set(anonymousSession, parseInt(anonymousCount) + 1);
}else{
@tsega
tsega / connectionStatus.js
Last active August 29, 2015 14:14
How to add connection id to onClose callback (on the Server side)?
Meteor.onConnection(function(connection){
connection.onClose(function(){
Posts.update({"viewers.sessionId": this.id}, {
$pull: {
viewers: {
sessionId: this.id
}
}
@tsega
tsega / mongo_db_date_between.js
Created December 1, 2015 15:40
How query MongoDB for values between dates
items.find({
created_at: {
$gte:"Mon May 30 18:47:00 +0000 2015",
$lt: "Sun May 30 20:40:36 +0000 2010"
}
})
@tsega
tsega / convert_pdf.rb
Last active February 11, 2016 11:08
A ruby command line script to generate jpg's from the first pages of pdf files.
#!/usr/bin/env ruby
# This require that you have ImageMagick and Ghostscript installed and available on your PATH
# It also assumes you have you pdf files in `pdfs` folder
# Note: Since it generates jpg's it does not handle transparency very well
# modify the .jpg to .png to generate png files.
Dir['pdfs/*.pdf'].each do |pdf_file|
jpg_file = pdf_file.chomp(File.extname(pdf_file)) + ".jpg"
system("convert -density 144 #{pdf_file}[0] -resize 200x300 #{jpg_file} ")