Skip to content

Instantly share code, notes, and snippets.

@gagoit
gagoit / simple-bash-and-github-action-for-creating-the-release-from-a-tag.md
Created October 28, 2020 09:22
Simple bash + Github Action for creating the release

Github action for creating the release from a tag

Create file .github/workflows/create-release-from-a-tag.yml with the content:

on:
  push:
    # Sequence of patterns matched against refs/tags
    tags:
      - 'release*' # Push events to matching release*, i.e. release-1.0, release-20.15.10, release-2020-10-28-10-26-15

name: Create Release
@gagoit
gagoit / faster_csv_downloads_using_enumerator.rb
Created January 25, 2019 07:35
Faster CSV downloads using Enumerator
Faster CSV downloads using Enumerator
https://medium.com/reflektive-engineering/faster-csv-downloads-using-enumerator-7e9b94b870d3
We do not have to download the full movie first to start watching it thanks to the concept of ‘media streaming’. In simple terms, we can download chunks of the movie in sequence while we’re watching the downloaded chunks.
Similarly, we can stream the CSV to the customer, rather than make them wait for the complete CSV to be generated.
This is possible because Rack, the middleware that Rails uses, requires the response object to support the #each method. Rack uses #each to send the response back in chunks.
In the current scenario, the CSV file that’s generated (Refer to Step#2 in the process) is a String. String does not support #each, and Rack is forced to send all of it in one shot, after it’s ready.
/*
* Binary Ajax 0.2
* Copyright (c) 2008 Jacob Seidelin, cupboy@gmail.com, http://blog.nihilogic.dk/
* Licensed under the MPL License [http://www.nihilogic.dk/licenses/mpl-license.txt]
*/
var BinaryFile = function(data, dataOffset, dataLength) {
var dataOffset = dataOffset || 0;
@gagoit
gagoit / gist:56f790c81963afe44977
Last active August 29, 2015 14:18
Fix: jQuery methods missing in IE8
/**
* String trim in IE8
**/
if(typeof String.prototype.trim !== 'function') {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
}
}
@gagoit
gagoit / will_paginate_boostrap.rb
Last active August 29, 2015 14:03
Rendering will_paginate links nicely with Twitter Bootstrap
##
# Rendering will_paginate links nicely with Twitter Bootstrap
# source: http://thehungrycoder.com/ruby-on-rails/will-paginate-links-and-twitter-bootstrap.html
# Modified for rendering pagination in Bootstrap 3
#
# Usage:
# + Put this file in config/initializers
# + When you embed the will_paginate in the view, you just need to pass this helper and the links will be rendered using this helper.
# = will_paginate(@collection, :renderer => 'BootstrapPaginationHelper::LinkRenderer')
##