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
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" |
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
constructor(props) { | |
super(props) | |
this.state = { | |
userName: 'Azat Mardan', | |
userEmail: 'hi@azat.co', | |
userId: 3967 | |
} | |
} | |
updateValues() { | |
this.setState({userName: 'Azat'}) |
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
import React, { Component } from "react"; | |
import ReactDOM from "react-dom"; | |
class App extends Component { | |
constructor() { | |
super(); | |
this.state = { data: [] }; | |
} | |
componentDidMount() { | |
fetch(`https://api.coinmarketcap.com/v1/ticker/?limit=10`) | |
.then(res => res.json()) |
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
def rdiff(yamla, yamlb, path='', key=getkey): | |
if isinstance(yamla, list) and isinstance(yamlb, list): | |
for d in listdiff(yamla, yamlb, path=path, key=key): | |
yield d | |
elif isinstance(yamla, dict) and isinstance(yamlb, dict): | |
for d in dictdiff(yamla, yamlb, path=path, key=key): | |
yield d | |
else: | |
if yamla != yamlb: | |
yield (path, 'value_difference', yamla, '-->', yamlb) |
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
def remove_empty_hash_element(h) | |
if h and h.length>0 | |
h.each do |k,v| | |
h.delete(k) if v.respond_to?('empty?') and v.empty? | |
end | |
end | |
end |
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
/* =========================================================================== | |
* Reverse the first len bits of a code, using straightforward code (a faster | |
* method would use a table) | |
* IN assertion: 1 <= len <= 15 | |
*/ | |
local unsigned bi_reverse(code, len) | |
unsigned code; /* the value to invert */ | |
int len; /* its bit length */ | |
{ | |
register unsigned res = 0; |
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
const size_t buffSize = 16 * 1024; // 16KB | |
size_t currReadSize = buffSize; // default | |
size_t dumpedSize = 0; | |
uint8 currBuff[buffSize]; | |
while (currAddr < endAddr) | |
{ | |
currReadSize = (currAddr + buffSize <= endAddr) ? buffSize : (size_t)(endAddr - currAddr); | |
read_memory(currBuff, currAddr, sizeof(uint8) * currReadSize, memory_type); | |
dumpedSize += currReadSize; | |
currAddr += currReadSize; |
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
item_names = mydict["items"].split() | |
if len(item_names) > 1: | |
item_names[-1] = "and " + dv_tiers[-1] | |
sep = ", " if len(item_names) > 2 else " " | |
namstr = sep.join(item_names) | |
print namestr # a, b and c |
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
import hudson.model.* | |
def str_view = "AIR_Project_A630" | |
def str_search = "air_a630" | |
def str_replace = "air_a630v1" | |
def view = Hudson.instance.getView(str_view) | |
//copy all projects of a view | |
for(item in view.getItems()) |
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 'pg' | |
require 'json' | |
def db_connect(host, dbname, user, password) | |
begin | |
conn = PGconn.connect(host, 5436, '', '', dbname, user, password) | |
rescue | |
puts "Failed to connect to database #{dbname} on #{host}" | |
end | |
return conn |
NewerOlder