It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.
This script is intended to automatically fix the sequence numbers for all tables in the current database.
This is accomplished through the use of the setval() command, which we provide with the next ID value we wish to make use of.
We use the setval(sequence, number, is_called) overload
and set is_called = false in conjunction with COALESCE(MAX + 1, 1) to ensure that, with an empty table, the next sequence
value is 1 as expected.
Since Twitter doesn't have an edit button, it's a suitable host for JavaScript modules.
Source tweet: https://twitter.com/rauchg/status/712799807073419264
const leftPad = await requireFromTwitter('712799807073419264');I would recommend @acdlite's redux-actions over the methods suggested in this Gist.
The methods below can break hot-reloading and don't support Promise-based actions.
Even though 'redux-actions' still uses constants, I've come to terms with the fact that constants can be good, especially in bigger projects. You can reduce boilerplate in different places, as described in the redux docs here: http://gaearon.github.io/redux/docs/recipes/ReducingBoilerplate.html
| // ------------ | |
| // counterStore.js | |
| // ------------ | |
| import { | |
| INCREMENT_COUNTER, | |
| DECREMENT_COUNTER | |
| } from '../constants/ActionTypes'; | |
| const initialState = { counter: 0 }; |
| import java.io.{IOException, File, ByteArrayOutputStream} | |
| import org.apache.avro.file.{DataFileReader, DataFileWriter} | |
| import org.apache.avro.generic.{GenericDatumReader, GenericDatumWriter, GenericRecord, GenericRecordBuilder} | |
| import org.apache.avro.io.EncoderFactory | |
| import org.apache.avro.SchemaBuilder | |
| import org.apache.hadoop.fs.Path | |
| import parquet.avro.{AvroParquetReader, AvroParquetWriter} | |
| import scala.util.control.Breaks.break | |
| object HelloAvro { |
| brew update | |
| brew install readline openssl rbenv ruby-build | |
| # follow the instructions in `brew info rbenv` to set up rbenv | |
| # or, if you already have those installed, just upgrade ruby-build to get the latest list of rubies | |
| brew update | |
| brew upgrade ruby-build |
| $ = jQuery | |
| $.fn.lineHeight or= -> | |
| if height = @data('lineHeight') | |
| return height | |
| # Create a hidden div with the same font | |
| # properties, then measure its height | |
| $shadow = $('<span />') | |
| $shadow.css({ |