Skip to content

Instantly share code, notes, and snippets.

Houssem Fathallah houssemFat

Block or report user

Report or block houssemFat

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View messenger_bot.rb
unless Rails.env.production?
bot_files = Dir[Rails.root.join('app', 'messenger_bot', '**', '*.rb')]
bot_reloader = ActiveSupport::FileUpdateChecker.new(bot_files) do
bot_files.each{ |file| require_dependency file }
end
ActionDispatch::Callbacks.to_prepare do
bot_reloader.execute_if_updated
end
@MarZab
MarZab / leaflet-custom-map.html
Last active Oct 5, 2017
Leaflet with latlng scale in meters and Control.Scale to match
View leaflet-custom-map.html
<!DOCTYPE html>
<html>
<head>
<title>Leaflet Custom Simple Map Example</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-1.0.0-b1/leaflet.css" />
<link rel="stylesheet" href="https://cdn.rawgit.com/ardhi/Leaflet.MousePosition/master/src/L.Control.MousePosition.css">
@MattWilcox
MattWilcox / build_nginx.sh
Last active Jul 3, 2019
Fetch, build, and install the latest nginx with the latest OpenSSL for RaspberryPi
View build_nginx.sh
#!/usr/bin/env bash
# names of latest versions of each package
export VERSION_PCRE=pcre-8.38
export VERSION_OPENSSL=openssl-1.0.2d
export VERSION_NGINX=nginx-1.9.7
# URLs to the source directories
export SOURCE_OPENSSL=https://www.openssl.org/source/
export SOURCE_PCRE=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
@soheilhy
soheilhy / nginxproxy.md
Last active Jul 12, 2019
How to proxy web apps using nginx?
View nginxproxy.md

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@paulmach
paulmach / serve.go
Last active Jul 5, 2019
Simple Static File Server in Go
View serve.go
/*
Serve is a very simple static file server in go
Usage:
-p="8100": port to serve on
-d=".": the directory of static files to host
Navigating to http://localhost:8100 will display the index.html or directory
listing file.
*/
package main
@dongyuwei
dongyuwei / horizontal-infinite-carousel.html
Created Jun 26, 2013
infinite loop carousel(vertical or horizontal)
View horizontal-infinite-carousel.html
@andelf
andelf / sendMail.go
Last active May 28, 2019
golang send mail net/smtp SMTP
View sendMail.go
package main
import (
"log"
"net/mail"
"encoding/base64"
"net/smtp"
"fmt"
"strings"
@victusfate
victusfate / canvas_bkg.js
Created Jun 28, 2012
creates a dynamic color pattern canvas on mouse move event
View canvas_bkg.js
var body, canvas, color, ctx, grad, canvasAdjust=true;
canvas = document.getElementsByTagName("canvas")[0];
ctx = null;
grad = null;
body = document.getElementsByTagName("body")[0];
color = 255;
if (canvas.getContext("2d")) {
var w = canvas.width;
var h = canvas.height;
ctx = canvas.getContext("2d");
@jwo
jwo / registrations_controller.rb
Created Sep 30, 2011
API JSON authentication with Devise
View registrations_controller.rb
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@fnichol
fnichol / README.md
Created Mar 12, 2011
Download a cacert.pem for RailsInstaller
View README.md

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

You can’t perform that action at this time.