Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Time for some Actions! :D

Michael managedkaos

💭
Time for some Actions! :D
View GitHub Profile
View docker-run-jenkins-hello-world.sh
/usr/local/bin/docker stop ${CONTAINER_NAME} || echo "no container to stop"
/usr/local/bin/docker rm ${CONTAINER_NAME} || echo "no container to remove"
# the insecure, no plugins install (skips the setup wizard)
/usr/local/bin/docker run \
-e 'JAVA_OPTS="-Djenkins.install.runSetupWizard=false"' \
--detach \
--publish ${PORT_NUMBER}:8080 \
--name ${CONTAINER_NAME} jenkins
@managedkaos
managedkaos / fizzbuzz.pl
Created Aug 8, 2017
FizzBuzz implemented in Perl.
View fizzbuzz.pl
#!/usr/bin/env perl
foreach $number (1..100) {
$three = 0;
$five = 0;
if (($number % 3) == 0) {
print 'Fizz';
$three = 1;
}
View mini-max-sum.pl
#!/usr/bin/env perl
# read the input
@data = split /\s+/, <STDIN>;
@data = sort @data;
map { $min += $_ } @data[0 .. ($#data - 1)];
map { $max += $_ } @data[1 .. $#data];
print "$min $max\n";
View compare-the-triplets.pl
#!/usr/bin/env perl
# read the input file
@input = <>;
# initialize the scores
@score = qw(0 0);
# split the input into arrays
foreach $i (0..1) {
View rockin_robin.py
arrays = [ [1,7], [2,3,4], [10,11,12,13] ]
while arrays:
for (index, item) in enumerate(arrays):
if len(arrays[index]) == 0:
arrays.pop(index)
continue
print arrays[index].pop(0)
print arrays
@managedkaos
managedkaos / array123.py
Created Aug 1, 2017
Given an array of ints, return True if the sequence of numbers 1, 2, 3 appears in the array somewhere. array123([1, 1, 2, 3, 1]) → True array123([1, 1, 2, 4, 1]) → False array123([1, 1, 2, 1, 2, 3]) → True
View array123.py
tests = {"1":[1,1,2,3,1],"2":[1,1,2,4,1],"3":[1,1,2,1,2,3]}
def array123(array):
if len(array) < 3:
return False
for (index, item) in enumerate(array):
if item == 1:
state1 = True
elif (item == 2) and state1:
@managedkaos
managedkaos / azlyrics.py
Created Aug 1, 2017
Scrape lyrics from azlyrics.com
View azlyrics.py
import requests
from bs4 import BeautifulSoup
url = "http://www.azlyrics.com/lyrics/onyx/bacdafucup.html"
print "Default request (it will fail)..."
# make the default request
try:
r = requests.get(url)
@managedkaos
managedkaos / github_status.py
Created Jul 31, 2017
A python script to scrape the status metrics from https://status.github.com/
View github_status.py
import requests
from bs4 import BeautifulSoup
# make a request for the data
r = requests.get('https://status.github.com/')
# convert the response text to soup
soup = BeautifulSoup(r.text, "lxml")
# get all the divs with the "graph" class
View second.pl
#!/usr/bin/env perl
# for hackerrank https://www.hackerrank.com/challenges/nested-list/problem
# read the input file
@input = <>;
# get the first line; that's the number of students
$count = shift @input;
# process the rest of the input...
@managedkaos
managedkaos / config.xml
Created Jun 8, 2017
Jenkins 'hello world' job
View config.xml
<?xml version='1.0' encoding='UTF-8'?>
<project>
<description>hello-world</description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>