This file contains 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
require 'builder' | |
# See more about syntax on | |
# http://api.rubyonrails.org/classes/ActionView/Base.html | |
# https://github.com/jimweirich/builder | |
# http://builder.rubyforge.org/ | |
xml = +"" | |
builder = Builder::XmlMarkup.new(target: xml, indent: 2) | |
builder.rootelementname { |x| |
This file contains 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
# # useradd storj | |
# $ install storj node as user as described in | |
# https://docs.storj.io/v1.1/docs/setting-up-storj-share-on-a-raspberry-pi | |
# * use chrony instead of ntpd (non mandatory but it is better) | |
# * use instructions up to start-farming.sh | |
# $ write this file as ~/.config/systemd/user/storj.service | |
# # loginctl enable-linger myuser | |
# # reboot | |
# # su - myuser | |
# XDG needed for https://bugzilla.redhat.com/show_bug.cgi?id=1531890 |
This file contains 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
# Start the sample server. This server alternates between responding with 100-continue and | |
# resopnding with a 403 Forbidden. The client **should** be able to handle both responses. | |
$ ruby server.rb | |
# In another terminal window, run the client code twice. The first invocation will succeed. | |
# The second invocation will fail the client with an error. | |
$ ruby client.rb | |
$ ruby client.rb |
This file contains 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
<?php | |
/** | |
* @package Joomla.Plugin | |
* @subpackage Captcha | |
* | |
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved. | |
* @license GNU General Public License version 2 or later; see LICENSE.txt | |
* @note Sorry for the ugliness, just a quick patch to make this work with the 2.0 API, it also connects through TLS now. Just replace original plugins/captcha/recaptcha/recaptcha.php | |
*/ |
This file contains 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
require 'test/unit' | |
# Read about the problem and mathematical proof here: | |
# http://www.greenteapress.com/thinkbayes/html/thinkbayes002.html#sec15 | |
class MontyHall | |
include Test::Unit::Assertions | |
NUM_DOORS = 3 |
This file contains 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
[Unit] | |
Description=FAHClient cruncher | |
After=syslog.target network.target | |
[Service] | |
Type=simple | |
User=fahclient | |
WorkingDirectory=/var/lib/fahclient | |
EnvironmentFile=-/etc/sysconfig/fahclient | |
# log will go fahclient home dir |
This file contains 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
// clone in sub-directory | |
checkout([ | |
$class: 'GitSCM', | |
branches: [[name: 'master']], | |
doGenerateSubmoduleConfigurations: false, | |
extensions: [[ | |
$class: 'RelativeTargetDirectory', | |
relativeTargetDir: 'some/path' | |
]], | |
submoduleCfg: [], |
This file contains 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
# the above works with synaps driver | |
DEV="SynPS/2 Synaptics TouchPad" | |
# DEV="Synaptics TM3053-006" | |
toggle_touchpad () { | |
local enabled=`xinput list-props "$DEV" | awk '/Device Enabled/{ print $4 }'` | |
case "$enabled" in | |
0) xinput enable "$DEV" | |
;; | |
1) xinput disable "$DEV" | |
;; |
This file contains 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
# rest-client recognizes files in multipart/form-data by checking | |
# the object type passed as the field content. We need to craft | |
# our string to appear as a file IO. `#stringfile` does that. | |
# An alternative approach is to just write string to a file and | |
# pass file IO to rest-client but this would be suboptimal | |
# provided we already have the content as a String. | |
def stringfile(string, | |
filename="file_#{rand 100000}", | |
type=MIME::Types.type_for("xml").first.content_type) |
This file contains 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
job = Jenkins.getInstance().getItem("Flexy-install") | |
println job.getProperty(ParametersDefinitionProperty.class)?.getParameterDefinition("REPOSITORIES")?.getDefaultParameterValue() | |
/* | |
License: https://en.wikipedia.org/wiki/WTFPL | |
Some readers: | |
https://support.cloudbees.com/hc/en-us/articles/226941767-Groovy-to-list-all-jobs | |
https://medium.com/@mukeshsingal/update-default-values-of-jenkins-job-parameters-416de5ff9f96 | |
https://javadoc.jenkins.io/hudson/model/Job.html |