Skip to content

Instantly share code, notes, and snippets.

View venkatd's full-sized avatar

Venkat Dinavahi venkatd

View GitHub Profile
@richard-flosi
richard-flosi / flutter-netlify-build.sh
Last active July 1, 2023 21:15
Netlify Build command script to deploy a Flutter Web App
#!/bin/sh
FLUTTER_BRANCH=`grep channel: .metadata | sed 's/ channel: //g'`
FLUTTER_REVISION=`grep revision: .metadata | sed 's/ revision: //g'`
git clone https://github.com/flutter/flutter.git
cd flutter
git checkout $FLUTTER_BRANCH
git pull origin $FLUTTER_BRANCH
git checkout $FLUTTER_REVISION
cd ..
@Nash0x7E2
Nash0x7E2 / Allow-multiple-gestures.dart
Last active November 3, 2023 08:56
[DEPRECATED] Sample code on how to enable gesture pass through so that both the parent and the child widget receive the gesture.
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
//Main function. The entry point for your Flutter app.
void main() {
runApp(
MaterialApp(
home: Scaffold(
body: DemoApp(),
),
defmodule Hyr.Command do
@moduledoc """
Define a command struct and an associated GraphQL mutation.
## Example
defmodule Hyr.Shifts.Opening.Commands.CancelOpeningEmployer do
use Hyr.Command
alias Hyr.Shifts.Opening.Schema.Opening
@jadeallenx
jadeallenx / discussion.md
Last active April 21, 2023 17:13
When does terminate/2 get called in a gen_server?

When does terminate/2 get called in a gen_server?

This is what the [official documentation][1] says about the terminate/2 callback for a gen_server:

This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.

Reason is a term denoting the stop reason and State is the internal state of the gen_server.

Reason depends on why the gen_server is terminating. If it is because another callback function has returned a stop tuple {stop,..}, Reason will have the value specified in that tuple. If it is due to a failure, Reason is the error reason.

@moklett
moklett / task1.exs
Last active May 7, 2024 09:59
Elixir Task - Crash Handling
# This demonstrates that, when using async/await, a crash in the task will crash the caller
defmodule Tasker do
def good(message) do
IO.puts message
end
def bad(message) do
IO.puts message
raise "I'm BAD!"
end
@schickm
schickm / gist:08ec48667a4d43e59d91
Last active September 24, 2017 21:33
Ember Dynamic aliases
import Ember from 'ember';
export default Ember.Object.extend({
model: null,
subpath: null,
dynamicModelProperty: Ember.computed('model', 'subpath', function() {
let subpath = this.get('subpath');
if ( subpath ) {
@jonyt
jonyt / connect_heroku_to_amazon_rds
Last active April 13, 2017 00:11
How to connect a Heroku application to an Amazon RDS Postgresql instance
Download the certificate with:
`wget -O config/rds-combined-ca-bundle.pem http://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem`
Then connect with:
`postgres://user:password@amazon-host/db_name?sslmode=require&sslrootcert=config/rds-combined-ca-bundle.pem`
References:
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html#PostgreSQL.Concepts.General.SSL
https://github.com/jeremyevans/sequel/issues/897
http://www.postgresql.org/docs/9.3/static/libpq-connect.html#LIBPQ-CONNECT-SSLROOTCERT
http://dba.stackexchange.com/questions/77811/how-to-connect-to-an-amazon-postgresql-database-using-ssl
anonymous
anonymous / jsbin.OxIDiVU.css
Created January 17, 2014 07:01
/* Put your CSS here */
html, body {
margin: 20px;
}
@venkatd
venkatd / tracer.rb
Created August 23, 2013 21:36
A wrapper around tracing that is easier to use and lets you filter what you want.
class Tracer
Trace = Struct.new(:event, :file, :line, :id, :binding, :klass)
def initialize(filename, params = {})
@filename = filename
@enabled = false
@classes = params.fetch(:classes) { [/.*/] }
@files = params.fetch(:files) { [/.*/] }
@venkatd
venkatd / hash_builder.rb
Created July 30, 2013 19:51
Very cool hash builder taken from stack overflow
class HashBuilder
def self.build &block
hb = HashBuilder.new
hb.instance_eval(&block)
hb.hash
end
attr_reader :hash