Skip to content

Instantly share code, notes, and snippets.

View geetotes's full-sized avatar

Lee Gillentine geetotes

View GitHub Profile
@jalcantarab
jalcantarab / _jsonPuller.md
Last active March 31, 2024 04:52 — forked from crstamps2/jsonPuller
A Google apps script to pull json from a spreadsheet

JSON Puller - Google Apps Script

Transforms the data of a given Spreadsheet Sheet to JSON.

  • The frozen rows are taken as keys for the JSON.
  • The data taken for the values is only that after the frozen rows

Set up:

exportJSON(Spreadsheet) - transforms the data in the given sheet to JSON.

class Author < ActiveRecord::Base
has_many :books
# this is bad
def scifi_books
books.by_category('scifi')
end
# this is better (with caveats?). The caveat is that as the number of associated records increases
# this will get slower, and may get to a point where it's best to fall back to a more complex SQL
@Faheetah
Faheetah / Jenkinsfile.groovy
Last active March 6, 2024 18:14
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"
@pathikrit
pathikrit / NQueen.scala
Last active January 19, 2023 21:30
O(n!) solution to the n-Queen puzzle (https://en.wikipedia.org/wiki/Eight_queens_puzzle)
/**
* Solves the n-Queen puzzle in O(n!)
* Let p[r] be the column of the queen on the rth row (must be exactly 1 queen per row)
* There also must be exactly 1 queen per column and hence p must be a permuation of (0 until n)
* There must be n distinct (col + diag) and n distinct (col - diag) for each queen (else bishop attacks)
* @return returns a Iterator of solutions
* Each solution is an array p of length n such that p[i] is the column of the queen on the ith row
*/
def nQueens(n: Int): Iterator[Seq[Int]] =
(0 until n)
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@geoffreyhale
geoffreyhale / PDO PHP Class
Last active September 14, 2022 04:27
Roll Your Own PDO PHP Class
<?php
/**
* http://culttt.com/2012/10/01/roll-your-own-pdo-php-class/
*/
?>
@ldlsegovia
ldlsegovia / osx-postgres-postgis.sh
Last active December 6, 2022 09:54
Installing postgis 2.1.4 with previously installed postgres 9.3.2 on OS X 10.9
$ brew install geos proj gdal libxml2 json-c
$ wget http://download.osgeo.org/postgis/source/postgis-2.1.4.tar.gz
$ tar xvfz postgis-2.1.4.tar.gz
$ cd postgis-2.1.4
$ ./configure --with-projdir=path-to-proj --with-jsondir=path-to-json-c (example: ./configure --with-projdir=/opt/boxen/homebrew/Cellar/proj/4.8.0 --with-jsondir=/opt/boxen/homebrew/Cellar/json-c/0.11)
$ make
$ sudo make install
$ cd path-to-your-postgres-previously-installed/contrib/postgis-2-1 (example: cd /opt/boxen/homebrew/Cellar/postgresql/9.3.2-boxen/share/postgresql/contrib/postgis-2.1)
$ createdb template_postgis
$ createlang plpgsql template_postgis
@tarjei
tarjei / Modal.jsx
Created June 17, 2014 11:02
Foundation.reveal as a React.js component
/**
* @jsx React.DOM
*/
var React = require('react/addons');
/* the link component is used to navigate away from th current url. Some of it is app spesific and
therefore not included here. */
var Link = require('../components/Link.jsx');
var cx = React.addons.classSet;
RSpec::Matchers.define :have_meta do |name, expected|
match do |actual|
has_css?("meta[name='#{name}'][content='#{expected}']")
end
failure_message_for_should do |actual|
actual = first("meta[name='#{name}']")
if actual
"expected that meta #{name} would have content='#{expected}' but was '#{actual[:content]}'"
else
@shanselman
shanselman / gist:5422230
Last active March 28, 2024 10:33
Evil Blog Comment Spammer just exposed his template through some error and the whole thing showed up in my comments.
{
{I have|I've} been {surfing|browsing} online more than {three|3|2|4} hours today, yet I never found any interesting article like yours. {It's|It
is} pretty worth enough for me. {In my opinion|Personally|In my view}, if all {webmasters|site owners|website owners|web owners} and bloggers made good content as
you did, the {internet|net|web} will be {much more|a lot more}
useful than ever before.|
I {couldn't|could not} {resist|refrain from} commenting. {Very well|Perfectly|Well|Exceptionally well} written!|
{I will|I'll} {right away|immediately} {take hold of|grab|clutch|grasp|seize|snatch}
your {rss|rss feed} as I {can not|can't} {in finding|find|to find} your {email|e-mail} subscription {link|hyperlink} or {newsletter|e-newsletter} service. Do {you have|you've} any?
{Please|Kindly} {allow|permit|let} me {realize|recognize|understand|recognise|know} {so that|in order that} I {may just|may|could} subscribe.
Thanks.|