- Every value is
true
exceptfalse
andnil
. - The number zero is
true
in Ruby. - Use the
nil?
method to differentiate betweenfalse
andnil
.
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
# `ERROR: Error installing nokogiri: | |
# ERROR: Failed to build gem native extension. | |
# | |
# current directory: /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/nokogiri-1.7.0/ext/nokogiri | |
# /usr/local/var/rbenv/versions/2.3.1/bin/ruby -r ./siteconf20170103-68488-r71c9j.rb extconf.rb --with-xml=/usr/local/Cellar/libxml2/ --use-system-libraries | |
# checking if the C compiler accepts ... yes | |
# checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no | |
# Building nokogiri using system libraries. | |
# ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed. | |
# *** extconf.rb failed *** |
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
const worker = null; | |
const start = (callback, delay) => { | |
const args = { foo: "abc" }; | |
worker = new Worker('/timeoutWorker.js'); | |
worker.onmessage = (event) => { | |
if (event.isTrusted && event.data === "timeout") { | |
callback(); | |
} |
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
const now = () => new Date().getTime() / 1000; | |
let values = {}; | |
let ttls = {} | |
const client = { | |
del: async (key) => { | |
delete values[key]; | |
}, | |
expire: async (key, ttl) => { |
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
-- convert from base-16 to base-36 (128bit precision) | |
CREATE FUNCTION conv(_hex TEXT) | |
RETURNS TEXT | |
BEGIN | |
DECLARE _hex_len TINYINT; | |
DECLARE _dec DECIMAL(65); | |
DECLARE _chars CHAR(36); | |
DECLARE _base36 TEXT; | |
DECLARE _mod TINYINT; |
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
#include "SevenSegmentTM1637.h" | |
#include "SevenSegmentExtended.h" | |
#include "RTClib.h" | |
// Sortie horloge Rouge | |
const byte PIN_CLK_Red = A0; // define CLK pin | |
// Sortie horloge Verte | |
const byte PIN_CLK_Green = A1; // define CLK pin | |
// Sortie horloge Orange | |
const byte PIN_CLK_Orange = A2; // define CLK pin |
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
<?php | |
// now | |
$date = date_create('2010-12-31 22:00:01', timezone_open('Europe/Amsterdam')); | |
// Buenos Aires | |
date_timezone_set($date, timezone_open('America/Argentina/Buenos_Aires')); | |
echo $date->format('Y-m-d H:i:s'); | |
// 2010-12-31 18:00:01 | |
// UTC |
10 Modern Software Over-Engineering Mistakes
- Engineering is more clever than Business? The House (Business) Always Wins.
- Reusable Business Functionality? Prefer Isolating Actions than Combining.
- Everything is Generic? Duplication is better than the wrong abstraction.
- Shallow Wrappers? Wrappers are an exception, not the norm. Don’t wrap good libraries for the sake of wrapping.
- Applying Quality like a Tool? Always take a step back and look at the macro picture. Concepts need shift in Mindset. Cannot be applied blindly like tools.
- Overzealous Adopter Syndrome? TL;DRs should not be used everywhere.
- –ity? Don’t let -ities go unchallenged. Clearly define and evaluate the Scenario/Story/Need/Usage.
- In House “Inventions”? Reuse. Fork. Contribute. Reconsider.
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
// Problem: when remembered, Chrome auto-fills the password input, but in fact it doesn't | |
// set the value and doesn't fire onChange event until there's any kind of interaction. | |
// If password value is empty, then submit button is still disabled yet password looks filled, | |
// which looks bad. See: https://bugs.chromium.org/p/chromium/issues/detail?id=813175 | |
const [isAutofilled, setIsAutofilled] = useState(false); | |
const passwordElRef = useRef<HTMLInputElement | null>(null); | |
useEffect(() => { | |
const element = passwordElRef.current; |
NewerOlder