Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Skudlarczyk chris-skud

View GitHub Profile
View .bash_profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@chris-skud
chris-skud / exec_cmdline_or_rspec.rb
Last active Aug 29, 2015
trick to exec ruby file from shell or rails
View exec_cmdline_or_rspec.rb
#!/usr/bin/env ruby
$:.unshift File.dirname(__FILE__)
require <the_module>
#run if command line, do not if required (called from rspec)
if $0 == __FILE__
require File.join(File.expand_path("..", Dir.pwd), 'path/to/other/rubies')
<TheClass>.provider_pull
end
View angular-service-promise.js
function get() {
var prom = $http({method:'GET', url: 'test.json'})
.then(function(data) {
//set local value with returned data
vals = data;
// and return to caller so they can .then(function(data){})
return vals;
@chris-skud
chris-skud / angular-console.js
Last active Aug 29, 2015
easy way to get at angular objects from dev tools console.
View angular-console.js
angular.element(document.querySelector('.ng-scope')).injector().get('theService')
@chris-skud
chris-skud / exclude_inherited_methods.rb
Created Nov 2, 2014
Ruby exclude inherited methods
View exclude_inherited_methods.rb
> Post.new.methods.count
> Post.new.methods.count - Object.new.methods.count
@chris-skud
chris-skud / whack_docker.sh
Created Jan 12, 2015
whack docker containers and images
View whack_docker.sh
docker rm -f $(docker ps -aq)
docker rmi -f $(docker images -q)
@chris-skud
chris-skud / gist:8a87bbe6be515c0d2783
Created Jun 9, 2015
shell curl parse json collection
View gist:8a87bbe6be515c0d2783
for json_val in $(curl -H "Content-Type: application/json; charset=utf-8" -H "Authorization: Bearer <secret>" https://thingthatreturnsjson | ./bin/JSON.sh |
egrep '^\[\d*,"id"\]\s\d*' | cut -f 2); do echo $json_val; sleep 3; done
View keybase.md

Keybase proof

I hereby claim:

  • I am chris-skud on github.
  • I am cskud (https://keybase.io/cskud) on keybase.
  • I have a public key whose fingerprint is D29A E245 B9F0 2419 981D F6A9 F4FF EAC3 67EF 5207

To claim this, I am signing this object:

@chris-skud
chris-skud / config-log.go
Last active Dec 1, 2017
log envconfig replacing sensitive values with stars
View config-log.go
package main
import (
"fmt"
"log"
"reflect"
"strings"
"github.com/kelseyhightower/envconfig"
)
@chris-skud
chris-skud / copy_ReadCloser.go
Created Jan 7, 2018
retain value of read closer by copying, reading, re-setting.
View copy_ReadCloser.go
// source https://medium.com/@xoen/golang-read-from-an-io-readwriter-without-loosing-its-content-2c6911805361
var bodyBytes []byte
if c.Request.Body != nil {
bodyBytes, _ = ioutil.ReadAll(c.Request.Body)
}
// Restore the io.ReadCloser to its original state
c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes))
// Use the content
bodyString := string(bodyBytes)