Skip to content

Instantly share code, notes, and snippets.

View synsa's full-sized avatar

Steve Lang synsa

View GitHub Profile
@synsa
synsa / replace_words.rb
Created May 31, 2022 17:34 — forked from jhjguxin/replace_words.rb
Read, edit, and write a text file line-wise using Ruby
# http://stackoverflow.com/questions/4397412/read-edit-and-write-a-text-file-line-wise-using-ruby
# files = Dir.glob(File.dirname(__FILE__)+"/../app/**/*.rb")
files = Dir[Rails.root.join("app", "**/*.rb")]
files.each do |f_name|
# puts f_name
File.open(f_name, "r+") do |f|
old_pos = 0
f.each do |line|
@synsa
synsa / gencert.rb
Created April 29, 2022 21:20 — forked from nmarley/gencert.rb
Ruby script to generate SSL certificates
#! /usr/bin/env ruby
#
# gencert.rb
# =====================================================================
# description: This script will accepts an FQDN as an argument
# and generates a Secure Sockets Layer (SSL)
# certificate request and a private key that corresponds
# to the request. It will not overwrite any existing
# files, so file <fqdn>.cnf , <fqdn>.csr , or <fqdn>.key
# exist, the program will print a message and exit.
@synsa
synsa / index.html
Created April 17, 2022 08:09 — forked from rpaul-stripe/index.html
Stripe Checkout Go Example
<html>
<head>
<title>Checkout Example</title>
</head>
<body>
<form action="/charge" method="post" class="payment">
<article>
<label class="amount">
<span>Amount: $5.00</span>
@synsa
synsa / readme.md
Created February 26, 2022 00:36 — forked from maxivak/readme.md
Provisioning Docker containers with Chef

Provisioning Docker container with Chef

Chef provisioning

  • Chef provisioning is a framework that allows clusters to be managed by the chef-client and the Chef server in the same way nodes are managed: with recipes.

  • Chef provisioning is a collection of resources that enable the creation of machines and machine infrastructures using the chef-client.

@synsa
synsa / display_model_names.rb
Created February 23, 2022 19:48 — forked from Kalaivanimurugan/display_model_names.rb
List all model names in rails console
Rails.application.eager_load!
ActiveRecord::Base.descendants # It returns all models and its attributes.
ApplicationRecord.descendants.collect(&:name) # It returns only the model names
@synsa
synsa / php5.4.Dockerfile
Created February 23, 2022 18:40 — forked from heckad/php5.4.Dockerfile
Dockerfile for creating container with php5.4 and xdebug
FROM php:5.4-apache
# This image is not to be used on a production server!
# I use it for local development on old projects (hence the PHP version).
# Install gd, iconv, mbstring, mcrypt, mysql, soap, sockets, and zip extensions
# see example at https://hub.docker.com/_/php/
RUN apt-get update
RUN apt-get install -y \
libbz2-dev \
@synsa
synsa / main.go
Created January 26, 2022 08:49 — forked from Skarlso/main.go
Golang SSH connection with hostkey verification
package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"golang.org/x/crypto/ssh"
kh "golang.org/x/crypto/ssh/knownhosts"
@synsa
synsa / userhomedir.go
Created January 26, 2022 08:41 — forked from miguelmota/userhomedir.go
Golang get user home directory path
package main
import (
"fmt"
"os"
"runtime"
)
func userHomeDir() string {
if runtime.GOOS == "windows" {
@synsa
synsa / fix-wordpress-permissions.sh
Created January 26, 2022 07:11 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
@synsa
synsa / wp-permissions-script
Created January 26, 2022 07:08 — forked from macbleser/wp-permissions-script
WordPress Permissions Configuration Script
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro
#
WP_OWNER=changeme # &lt;-- wordpress owner
WP_GROUP=changeme # &lt;-- wordpress group
WP_ROOT=/home/changeme # &lt;-- wordpress root directory