Skip to content

Instantly share code, notes, and snippets.

@nateflink
nateflink / new_gist_file
Created September 16, 2013 16:15
Bash send mail
cat <<EOF | sendmail -t
To: [email protected]
Subject: Testing
From: [email protected]
This is a test message
EOF
<script type="text/javascript">
function getCookie( name ) {
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ';', len );
if ( end == -1 ) end = document.cookie.length;
#!/bin/bash
#By Nate Flink
#Invoke on the terminal like this
#curl -s https://gist.github.com/nateflink/9056302/raw/findreplaceosx.sh | bash -s "find-a-url.com" "replace-a-url.com"
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: ./$0 [find string] [replace string]"
exit 1
fi
@nateflink
nateflink / gist:946aa10d3872ba896ea9
Last active August 29, 2015 14:04
MYSQL create db
CREATE USER 'foobaz'@'%' IDENTIFIED BY 'foopassword';
CREATE DATABASE IF NOT EXISTS `foobaz` ;
GRANT ALL PRIVILEGES ON foobaz.* TO foobaz@localhost IDENTIFIED BY 'foopassword';
;superuser
CREATE USER 'user'@'%' IDENTIFIED BY 'pass';
GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' WITH GRANT OPTION;
CREATE USER 'user'@'localhost' IDENTIFIED BY 'pass';
[
//
// TABS (REGULAR)
//
// Tab set
{
"class": "tabset_control",
"layer0.texture": "",
@nateflink
nateflink / gist:9f49dbe3f2efb7b6b51d
Created March 18, 2015 00:32
JS function to determine if two strings are anagrams
function check_anagrams(first_words, second_words) {
if (first_words.length != second_words.length) {
console.log(0);
return;
}
var letters=[], is_anagram, first_word, second_word, exists;
for (var i=0; i<first_words.length; i++) {
@nateflink
nateflink / gist:f3652012615117488c47
Created May 5, 2015 21:58
Bash Alias Made Easy
#alias to reload the bash profile after adding an alias
alias sourcebash="source ~/.bash_profile"
#alias to quickly add an alias to the bash profile
alias aliasappend=aliasappendfunction
aliasappendfunction() {
echo 'alias '$1'="'$2'"' >> ~/.bash_profile;
sourcebash
}
<?php
$xml_post_string =
'<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.edocbuilder.com/">
<SOAP-ENV:Body>
<ns1:getOrderFile>
<ns1:docSessionID>replace-with-real-a49a-3862345df1061</ns1:docSessionID>
<ns1:email>EMAIL</ns1:email>
<ns1:password>PASSWORD</ns1:password>
</ns1:getOrderFile>
@nateflink
nateflink / ruby
Created June 27, 2018 03:26
pad dollars
val = "32.244"
if val.is_a? String
if val.match /\d+\.\d\d$/
val
elsif val.match /(\d+\.\d\d)\d+$/
$1
elsif val.match /\d+\.\d$/
val+'0'
elsif val.match /\d+\.$/
val+'00'
<% unless current_user.stripe_charge_id_opencall_2017.blank? %>
<div class="ui green message"> The provided card has been charged. </div>
<% else %>
<div class="ui grid">
<div class="twelve wide column">
<h4>You will only be charged once.</h4>
<p>Payment processing occurs offsite via Stripe payments. Your credit information is not stored on this site.</p>
</div>