Skip to content

Instantly share code, notes, and snippets.

View rs77's full-sized avatar

Ryan rs77

View GitHub Profile
@rs77
rs77 / meteor-nginx.conf
Created April 26, 2014 09:46
Current process in deploying a Meteor app to my own server: 1. Edit meteor.sh file for app name and port number (must be a unique port number that isn't used); 2. run `./meteor.sh deploy` in folder; 3. once done access server and create/modify the new app's nginx config file
upstream app_name {
server localhost:PORT; # PORT being the unique port number assigned in the meteor.sh file
}
server {
listen 80;
server_name domain.com www.domain.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@rs77
rs77 / SACC-select.html
Created February 23, 2015 20:17
Standard Australian Classification of Countries (SACC) 2011 version 2.3 placed into alphabetical order (bar Australia & New Zealand) for use as a dropdown menu returning the SACC 4-digit code as value from selected country.
<select>
<option value='1101'>Australia</option>
<option value='1201'>New Zealand</option>
<option value='1601'>Adelie Land (France)</option>
<option value='7201'>Afghanistan</option>
<option value='2408'>Aland Islands</option>
<option value='3201'>Albania</option>
<option value='4101'>Algeria</option>
<option value='3101'>Andorra</option>
<option value='9201'>Angola</option>
@rs77
rs77 / SACC-Languages.html
Created February 24, 2015 19:43
Australian Standard Classification of Languages placed in alphabetical order corresponding to their 4-digit classification
<select>
<option value='8998'>Aboriginal English, so described</option>
<option value='6513'>Acehnese</option>
<option value='9201'>Acholi</option>
<option value='8901'>Adnymathanha</option>
<option value='9299'>African Languages, nec</option>
<option value='1403'>Afrikaans</option>
<option value='9203'>Akan</option>
<option value='8121'>Alawa</option>
<option value='3901'>Albanian</option>
@rs77
rs77 / SACC-Countries.php
Created March 22, 2015 04:15
Standard Australian Classification of Countries (SACC) 2011 version 2.3 placed into alphabetical order (bar Australia & New Zealand) for use as an array of key => value pairs for use in PHP
array( '1101' => "Australia",'1201' => "New Zealand",'1601' => "Adelie Land (France)",'7201' => "Afghanistan",'2408' => "Aland Islands",'3201' => "Albania",'4101' => "Algeria",'3101' => "Andorra",'9201' => "Angola",'8401' => "Anguilla",'8402' => "Antigua and Barbuda",'8201' => "Argentina",'1602' => "Argentinian Antarctic Territory",'7202' => "Armenia",'8403' => "Aruba",'1603' => "Australian Antarctic Territory",'2301' => "Austria",'7203' => "Azerbaijan",'8404' => "Bahamas",'4201' => "Bahrain",'7101' => "Bangladesh",'8405' => "Barbados",'3301' => "Belarus",'2302' => "Belgium",'8301' => "Belize",'9101' => "Benin",'8101' => "Bermuda",'7102' => "Bhutan",'8202' => "Bolivia [Plurinational State of]",'8433' => "Bonaire (Sint Eustatius and Saba)",'3202' => "Bosnia and Herzegovina",'9202' => "Botswana",'8203' => "Brazil",'1604' => "British Antarctic Territory",'5201' => "Brunei Darussalam",'3203' => "Bulgaria",'9102' => "Burkina Faso",'9203' => "Burundi",'9104' => "Cabo Verde",'5102' => "Cambodia",'9103' => "Cameroon"
@rs77
rs77 / SACC-Language.php
Created March 22, 2015 04:21
Australian Standard Classification of Languages placed in alphabetical order corresponding to their 4-digit classification as an array of key => value pairs for PHP
array( '1201' => "English",'8998' => "Aboriginal English, so described",'6513' => "Acehnese",'9201' => "Acholi",'8901' => "Adnymathanha",'9299' => "African Languages, nec",'1403' => "Afrikaans",'9203' => "Akan",'8121' => "Alawa",'3901' => "Albanian",'8315' => "Alngith",'8603' => "Alyawarr",'9101' => "American Languages",'9214' => "Amharic",'8156' => "Amurdak",'8101' => "Anindilyakwa",'8619' => "Anmatyerr, nec",'8607' => "Antekerrepenh",'8703' => "Antikarinya",'9241' => "Anuak",'8902' => "Arabana",'4202' => "Arabic",'8699' => "Arandic, nec",'4901' => "Armenian",'8199' => "Arnhem Land and Daly River Region Languages, nec",'3903' => "Aromunian (Macedo-Romanian)",'8629' => "Arrernte, nec ",'5213' => "Assamese",'4206' => "Assyrian Neo-Aramaic",'9701' => "Auslan",'4302' => "Azeri",'8946' => "Baanbay",'8947' => "Badimaya",'6514' => "Balinese",'4104' => "Balochi",'8903' => "Bandjalang",'8904' => "Banyjima",'8948' => "Barababaraba",'8801' => "Bardi",'9242' => "Bari",'2901' => "Basque",'9243' => "Bassa",'8905' => "Batj
@rs77
rs77 / modifyDeptLines.js
Created May 16, 2015 10:52
Couldn't find an easy way to change the Department field on a per line basis in NetSuite, so ended up using a jQuery hack that ran in the browser's console.
jQuery("td:contains('Company (10)')").each(
function( i, el ) {
jQuery(el).click();
jQuery("input[name='department']").val("9");
jQuery("input#indx_department").val("23");
jQuery("input[name='department_display']").val("Trading (18 CEM)");
jQuery("input#item_addedit").click();
}
);
Function AlphaNumericOnly(strSource As String) As String
Dim i As Integer
Dim strResult As String
For i = 1 To Len(strSource)
Select Case Asc(Mid(strSource, i, 1))
Case 32, 48 To 57: 'include 32 if you want to include space
strResult = strResult & Mid(strSource, i, 1)
End Select
Next
if ( cell.length || cell ) // testing if a cell contains something other than an empty string or 0
// parsing through sheet - best practice, grab entire sheet and loop through array
data = sht.getDataRange().getValues();
for ( var r = 0; r < data.length; r += 1 ) { // rows are looped through first
for ( var c = 0; c < data[0].length; c += 1 ) { // columns are next
data[r][c];
}
}
var p = 25000, // principal amount
i = 0.06, // annual interest rate over the life HP
n = 60, // number of periods in life of HP
y = 12, // number of payment periods per annum
t = true, // if payment is to be made in ADVANCE
r = 1 + ( i / y ), // interest rate per period = 1.005
S_n = ( (r^n) - 1 ) ) / ( r - 1 ), // limiting sum of payments = 69.77
repay; // repayments per period
if ( t ) S_n *= r; // = 70.12
@rs77
rs77 / getElementFrom2dArray.js
Last active August 29, 2015 14:21
This function is handy when working with Google App Script for Spreadsheets and you need to get an array out of the 2-dimensional getValues() call. In fact, you may want to look at this performance test and see that running indexOf on array data may be quite slow in comparison to their for-loop and while-loop counterparts as seen here: http://js…
function findElem( el ) {
return !!~el.indexOf( this.val );
}
// for example:
var arr = [ [ 18, "AAA" ], [ 19, "BBB" ], [ 20, "CCC" ] ];
var query = 19;
console.log( arr.filter( findElem, { val: query } ) ); // returns [[19, "BBB"]]