Skip to content

Instantly share code, notes, and snippets.

@jmacqueen
jmacqueen / application.js
Created October 6, 2016 16:06
Create an Ember application instance that can be imported into any file. Useful for container lookups in files outside of the usual hierarchy.
// app/instance-initializers/application.js
import appInst from 'appName/utils/application'
export function initialize( appInstance ) {
appInst.instance = appInstance
}
export default {
name: 'application',
initialize
};
@imranismail
imranismail / README.md
Last active July 28, 2017 08:48
Repo composition

Repo Composition

Motive

Ecto.Repo by default doesn't allow overrides. So when you need to compose functions but maintain an API parity with the Ecto.Repo. You'd need to compose the functions in another module and things can get messy really fast that way.

Can't invoke super

== Compilation error on file lib/app/repo.ex ==
** (CompileError) lib/app/repo.ex:6: no super defined for all/2 in module App.Repo. Overridable functions available are:
@sheharyarn
sheharyarn / request.js
Last active August 24, 2023 14:55
Axios Request Wrapper for React (https://to.shyr.io/axios-requests)
/**
* Axios Request Wrapper
* ---------------------
*
* @author Sheharyar Naseer (@sheharyarn)
* @license MIT
*
*/
import axios from 'axios'
@imranismail
imranismail / attachment.ex
Created January 1, 2017 16:54
Media Prototype
defmodule Blog.Attachment do
use Blog, :schema
@primary_key {:id, :binary_id, autogenerate: true}
@storage_path "attachments"
schema "attachments" do
field :file, :any, virtual: true
belongs_to :post, Post
@chrismccord
chrismccord / upgrade.md
Last active April 7, 2023 12:03
Phoenix 1.2.x to 1.3.0 Upgrade Instructions

If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8

To use the new phx.new project generator, you can install the archive with the following command:

$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez

Bump your phoenix dep

Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in mix.exs:

@imranismail
imranismail / readme.md
Last active April 23, 2017 12:16
Tips on Elixir that you might not know of

Elixir Tips and Tricks That You Might Not Know Of

SaaS/Multitenant Migrations with Ecto

defmodule App.Team do
  use App, :schema

  ...
@febridev
febridev / controller.php
Created April 3, 2017 16:18
eloquent laravel group by year
// Carbon
use Carbon\Carbon;
$visitorTraffic = PageView::select('id', 'title', 'created_at')
->get()
->groupBy(function($date) {
return Carbon::parse($date->created_at)->format('Y'); // grouping by years
//return Carbon::parse($date->created_at)->format('m'); // grouping by months
});
@Rajeshr34
Rajeshr34 / wkhtmltopdf.sh
Last active May 29, 2024 08:44
Wkhtmltopdf With Patched QT Setup Ubuntu 16+
cd ~
apt-get install libfontenc1 xfonts-75dpi xfonts-base xfonts-encodings xfonts-utils openssl build-essential libssl-dev libxrender-dev git-core libx11-dev libxext-dev libfontconfig1-dev libfreetype6-dev fontconfig -y
#https://github.com/wkhtmltopdf/wkhtmltopdf/releases
#replace arch
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb
apt --fix-broken install
@boverby
boverby / mqtt_esp8266wemos.ino
Created May 26, 2017 20:43
mqtt_esp8266wemos - simple mqtt sender and receiver for wemos d1 mini. mac address is part of topic.
/*
Simple wemos D1 mini MQTT example
This sketch demonstrates the capabilities of the pubsub library in combination
with the ESP8266 board/library.
It connects to the provided access point using dhcp, using ssid and pswd
It connects to an MQTT server ( using mqtt_server ) then:
- publishes "connected"+uniqueID to the [root topic] ( using topic )
@DawidMyslak
DawidMyslak / vue.md
Last active April 22, 2024 12:49
Vue.js and Vuex - best practices for managing your state

Vue.js and Vuex - best practices for managing your state

Modifying state object

Example

If you have to extend an existing object with additional property, always prefer Vue.set() over Object.assign() (or spread operator).

Example below explains implications for different implementations.