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
@barek2k2
barek2k2 / _head.html.erb
Created November 5, 2012 07:53
Javascript code used in header should be used in footer but not in home page and campaign page
<script type="text/javascript">
function recordOutboundLink(link, category, action) {
_gat._getTrackerByName()._trackEvent(category, action);
setTimeout('document.location = "' + link.href + '"', 100);
}
</script>
<%= render "shared/analytics" %>
<script type="text/javascript">
function recordOutboundLink(link, category, action) {
_gat._getTrackerByName()._trackEvent(category, action);
<script type="text/javascript">
$(function() {
updateState();
$("#front_stat").submit(function() {
updateState();
return false;
});
});
function updateState(){
curl -v -H "Accept: application/json" -H "Ctent-type: application/json" -X POST -d ' {"answer":{"it_description": "grtgrt"}}' http://localhost:3000/api/v1/risposte/15712/save_answer
@barek2k2
barek2k2 / gist:5520967
Last active December 17, 2015 00:29
Apache an nginx configuration for browser cache for static resources
For Apache, use the Location directive into your virtual host(be sure you have included expires and headers modules)
<LocationMatch "^/assets/.*$">
Header unset ETag
FileETag None
ExpiresActive On
ExpiresDefault "access plus 30 days"
</LocationMatch>
@barek2k2
barek2k2 / gist:5520990
Created May 5, 2013 14:40
varnish configuration
/etc/varnish/default.vcl
backend default {
.host = "127.0.0.1";
.port = "8080";
}
acl purge {
"localhost";
}
@barek2k2
barek2k2 / gist:5521021
Created May 5, 2013 14:49
Parallel processing on Ruby On Rails using fork
fork do
ActiveRecord::Base.establish_connection
for i in 0..20000
puts 'I m in sub process-1'
end
exit
end
fork do
ActiveRecord::Base.establish_connection
for i in 2001..40000
@barek2k2
barek2k2 / gist:5521112
Created May 5, 2013 15:26
Drawing images from text in ruby on rails application
def draw_image
#Image parameters
options = {:img_width =&gt; 300, :img_height =&gt; 250, :text_color =&gt; "#FF0000", :font_size =&gt; 36,
:text =&gt; "This is text", :bg_color =&gt; "#EFEFEF"}
#Initialize a container with it's width and height
container=Magick::Image.new(options[:img_width],options[:img_height]){
self.background_color = options[:bg_color]
}
@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)->
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: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">