This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENV['GOOGLE_APPLICATION_CREDENTIALS'] = "#{ENV['HOME']}/google-service-account.json" | |
scopes = ['https://www.googleapis.com/auth/drive'] | |
drive = Google::Apis::DriveV2::DriveService.new | |
auth_client = Google::Auth.get_application_default(scopes).dup | |
auth_client.sub = '[email protected]' | |
drive.authorization = auth_client | |
report_folders = drive.list_files(q: "title = 'Reports'") | |
raise "Expected 1 folder called 'Reports', found #{report_folders.items.count}" if report_folders.items.count != 1 | |
parent_id = report_folders.items[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('myapp.directive.blacklist', []). | |
directive('maBlacklist', [ | |
function() { | |
return { | |
restrict: 'A', | |
require: 'ngModel', | |
scope: {'blacklist':'=gsBlacklist'}, | |
link: function($scope, $elem, $attrs, modelCtrl) { | |
var check = function(value) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
port=8080 | |
max_tries=10 | |
seconds_to_wait=3 | |
echo "Waiting for traffic on port $port to stop..." | |
for (( tries=1; tries<=$max_tries; tries++ )); do | |
# Netstat invocation tested on Ubuntu. Check your distro for differences. | |
connections=$(netstat -ant | grep ":$port.*:.*ESTABLISHED" | wc -l) | |
echo " $connections connections remaining. Try $tries/$max_tries." | |
if [ $connections -eq 0 ]; then | |
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cadrlife; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class ShellSplitter { | |
public List<String> shellSplit(CharSequence string) { | |
List<String> tokens = new ArrayList<String>(); | |
boolean escaping = false; | |
char quoteChar = ' '; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo iptables -t nat -N hot-deploy | |
sudo iptables -t nat -A PREROUTING -j hot-deploy | |
# Enable first server | |
sudo iptables -t nat -A hot-deploy -p tcp --dport 80 -j REDIRECT --to-ports 8080 | |
# Enable second | |
sudo iptables -t nat -A hot-deploy -p tcp --dport 80 -j REDIRECT --to-ports 8081 && sudo iptables -t nat -D hot-deploy 1 | |
# Back to first |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task checkCompileDependenciesJava5Compatibility << { | |
configurations.compile.each { dep -> | |
def failureReason | |
zipTree(dep).matching { include("**/*.class") }.visit { fileDetails -> | |
if (!fileDetails.isDirectory()) { | |
def stream = fileDetails.file.newDataInputStream() | |
def magic1 = stream.readUnsignedShort() | |
def magic2 = stream.readUnsignedShort() | |
stream.skipBytes(2); // minor version | |
def majorVersion = stream.readUnsignedShort() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'java' | |
apply plugin : 'war' | |
group = 'com.cadrlife' | |
version = '1.0.0' | |
buildscript { | |
repositories { | |
mavenCentral() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cadrlife; | |
import org.eclipse.jetty.server.Server; | |
import org.eclipse.jetty.webapp.WebAppContext; | |
public class EmbeddedJetty9Server { | |
// compile 'org.eclipse.jetty:jetty-server:9.0.0.v20130308' | |
// compile 'org.eclipse.jetty:jetty-webapp:9.0.0.v20130308' | |
public static void main(String[] args) throws Exception { | |
Server server = new Server(8080); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'java' | |
apply plugin: 'eclipse' | |
apply plugin : 'war' | |
apply plugin : 'jetty' | |
sourceCompatibility = 1.7 | |
version = '0.1' | |
group = 'org.computermentor' | |
version = '1.0.0' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cadrlife.blog; | |
import com.google.common.base.Function; | |
import com.google.common.collect.FluentIterable; | |
import com.google.common.collect.ImmutableList; | |
import com.google.common.collect.Iterables; | |
public class LazySequencer { | |
public static <T> Iterable<? extends Iterable<T>> subn(int n, Iterable<T> li) { | |
if (n == 0) { |