Skip to content

Instantly share code, notes, and snippets.

Cheyne Wallace cheynewallace

Block or report user

Report or block cheynewallace

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 gist:4943c19f56095de62db633a11693710a
**Routes**
resources :books do
get 'search', :on => :collection
end
**Forms**
<%= form_with(model: book, local: true) do |form| %>
<%= label_tag(:name, "Name:") %>
<%= form.text_field :name %>
<%= label_tag(:description, "Description:") %>
@cheynewallace
cheynewallace / nginx-ssl-wordpress-letsencrypt
Last active Jun 28, 2018
Nginx Site Running WordPress SSL Config Using LetsEncrypt Cert
View nginx-ssl-wordpress-letsencrypt
server {
listen 80;
server_name yoursite.com www.yoursite.com;
return 301 https://www.yoursite.com$request_uri;
}
# HTTPS server
server {
listen 443;
server_name www.yoursite.com yoursite.com;
@cheynewallace
cheynewallace / asana_unicorns.js
Created May 13, 2015
Infinite Asana Unicorns
View asana_unicorns.js
setInterval(function(){
env.dynamic_loader.load({url:CommonUrl.staticUrl({path:"apps/asana/view/asana_rainbow.js", compute_hash:!1}), allow_cached:!1 , callback:function(a, b) {
b && AsanaRainbow.start()
}})},1000)
@cheynewallace
cheynewallace / unicorn
Last active Aug 29, 2015
Run Rails Unicorn Server As Ubuntu Service
View unicorn
# Add this line to your web app users crontab to start unicorn after reboot
@reboot service unicorn start
@cheynewallace
cheynewallace / dns_export.bat
Created Apr 1, 2014
Export DNS Zone As Text File Info To %windir%\System32\dns. Takes single zone name as parameter
View dns_export.bat
@ECHO OFF
REM Run this with: dns_export.bat <your_zone_name>
ECHO ###############################
ECHO ## REMOVING OLD ZONE EXPORT ##
ECHO ###############################
del C:\Windows\System32\dns\%1.txt
ECHO
ECHO ###########################################
ECHO ## EXPORTING %1 ZONE DNS CONFIGURATION ##
ECHO ###########################################
@cheynewallace
cheynewallace / ExportSchema.ps1
Last active Aug 10, 2019
Export MSSQL schema with PowerShell. This script will export your schema definitions for tables, stored procs, triggers, functions and views to .sql files
View ExportSchema.ps1
# Usage: powershell ExportSchema.ps1 "SERVERNAME" "DATABASE" "C:\<YourOutputPath>"
# Start Script
Set-ExecutionPolicy RemoteSigned
# Set-ExecutionPolicy -ExecutionPolicy:Unrestricted -Scope:LocalMachine
function GenerateDBScript([string]$serverName, [string]$dbname, [string]$scriptpath)
{
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null
@cheynewallace
cheynewallace / mysql_create_db_user_grant.sql
Last active Jan 25, 2018
Simple script using prepared statements to create a MySQL database, with user that has same name as the database, then grant the user full permissions on the database. Simply change the two variable assignments at the top
View mysql_create_db_user_grant.sql
# Only change these two variables.
# DATABASENAME is used for both the database name and username
SET @DATABASENAME = "service_abc";
SET @USERPASSWORD = "password123";
# ======== PERFORM =========
# Drop Database If Exists
SET @DROP_DB = concat("DROP DATABASE IF EXISTS ",@DATABASENAME);
@cheynewallace
cheynewallace / NetStatPortsAndProcessNames.cs
Last active Sep 7, 2019
C# Get Active Ports and Associated Process Names. This code will parse the output from a "netstat -a -n -o" and retrieve a list of active listening ports, along with the associated PID. The PID is then resolved to a process name so we can see exactly which port is attached to which process.
View NetStatPortsAndProcessNames.cs
// ===============================================
// The Method That Parses The NetStat Output
// And Returns A List Of Port Objects
// ===============================================
public static List<Port> GetNetStatPorts()
{
var Ports = new List<Port>();
try {
using (Process p = new Process()) {
@cheynewallace
cheynewallace / ga-event-tracker.js
Last active Oct 18, 2018
jQuery Google Analytics Event Tracking Using HTML Attributes
View ga-event-tracker.js
/*JSHint Options*/
/*global _gaq */
/*
Google Analytics Event Tracking - JSHint Checked
Written By Cheyne Wallace - 19th Nov 2012
Click Usage: <a href="http://somewhere"
class="ga-track"
event_category="Event Category"
event_action="Specific Action"
event_label="Optional Message"
You can’t perform that action at this time.