Skip to content

Instantly share code, notes, and snippets.

View andrewostroumov's full-sized avatar

Andrew Ostroumov andrewostroumov

View GitHub Profile
@JohnZavyn
JohnZavyn / my_sql_encryption.rb
Created May 14, 2018 18:46
MySQL AES Encryption for Ruby
require 'openssl'
# This module provides AES encryption compatible with MySQL AES_ENCRYPT
# and AES_DECRYPT functions.
module MySQLEncryption
# Takes an unencrypted text string, encrypts it with the password,
# and encodes the results to a hexadecimal string
def self.mysql_encrypt(unencrypted_text, password)
encrypt(unencrypted_text, mysql_key(password))
@enricofoltran
enricofoltran / main.go
Last active July 25, 2024 03:38
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@arxdsilva
arxdsilva / working_directory.go
Last active February 12, 2024 13:30
How to get the current working directory in golang
package main
// More info on Getwd()
// https://golang.org/src/os/getwd.go
//
import(
"os"
"fmt"
"log"
)
@shivakar
shivakar / tls-server-in-memory-cert.go
Created December 12, 2015 17:16
TLS server with in-memory self-signed certificate
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"errors"
"log"
@hongster
hongster / tcp_timeout.go
Created October 2, 2015 11:30
Golang example on handling TCP connection and setting timeout.
package main
import (
"fmt"
"net"
"time"
"bufio"
)
func handleConnection(conn net.Conn) {
@danshultz
danshultz / host-ember-app.md
Created March 1, 2015 21:13
Hosting Ember App on S3
  1. Use ember-deploy + ember-deploy-s3 + ember-deploy-s3-index
  2. npm install --save-dev ember-deploy ember-deploy-s3 ember-deploy-s3-index
  3. Update nginx with the following config
server {
  listen 80;
  server_name foo.example.dev;
  location / {
    set $s3_bucket 'my-ember-app-index.s3.amazonaws.com';
    set $url_full         '$1';
@ngauthier
ngauthier / timeout_and_tick.go
Created February 10, 2015 18:14
Golang timeout and tick loop
// keepDoingSomething will keep trying to doSomething() until either
// we get a result from doSomething() or the timeout expires
func keepDoingSomething() (bool, error) {
timeout := time.After(5 * time.Second)
tick := time.Tick(500 * time.Millisecond)
// Keep trying until we're timed out or got a result or got an error
for {
select {
// Got a timeout! fail with a timeout error
case <-timeout:
@jurre
jurre / bench.rb
Created January 13, 2015 10:51
roar vs ams
require "bundler"
require "active_model_serializers"
require "roar"
require "roar/json/json_api"
require "benchmark"
require "ffaker"
Post = Struct.new(:id, :author, :body, :draft) do
include ActiveModel::Serializers::JSON
end
@ChuckJHardy
ChuckJHardy / digital_ocean_setup.md
Last active October 27, 2023 17:51
DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3 Setup Instructions

DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3

SSH into Root

$ ssh root@123.123.123.123

Change Root Password