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
test_info = Hash.new do |hash, key| | |
hash[key] = Hash.new | |
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
# Use Gists to store entire functions | |
class QuickSort | |
def self.sort!(keys) | |
quick(keys,0,keys.size-1) | |
end | |
private | |
def self.quick(keys, left, right) |
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
#!/usr/bin/env ruby | |
USAGE=<<EOS | |
Delete files in specified folders that are older than a given number of days. | |
Options: | |
-v - verbose. Will list folders and files. | |
-d - dry run. Like verbose, but does not delete files. | |
-h - Show this usage help. | |
Arguments: |
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
test_num = test_list.length | |
group_num = test_num / group_length | |
if test_num % group_length != 0 | |
group_num += 1 | |
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
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 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; |
OlderNewer