Skip to content

Instantly share code, notes, and snippets.

View syamilmj's full-sized avatar

Syamil MJ syamilmj

View GitHub Profile
@syamilmj
syamilmj / example.exs
Created January 19, 2024 01:07
Nested Form in Live Component Bug
Application.put_env(:sample, Example.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 5001],
server: true,
live_view: [signing_salt: "aaaaaaaa"],
secret_key_base: String.duplicate("a", 64)
)
Mix.install([
{:plug_cowboy, "~> 2.5"},
{:jason, "~> 1.0"},
@syamilmj
syamilmj / http.ex
Created December 15, 2016 09:56
HTTP Client base
defmodule Crux.Http do
use HTTPoison.Base
def process_url(url) do
Application.get_env(:crux, :api) <> url
end
def process_request_body(body) when is_map(body) do
Poison.encode!(body)
end
@syamilmj
syamilmj / enum.ex
Created October 29, 2016 07:31
Add enum datatype support to Ecto
defmodule Inventory.Enum do
@moduledoc """
Provides macro to support Enum datatype with Ecto
## Usage
In your model:
import Inventory.Enum
@syamilmj
syamilmj / rails_cheatsheet.md
Created March 23, 2016 10:18 — forked from azinazadi/rails_cheatsheet.md
Rails cheatsheet

An incomplete cheatsheet for rails 3. Things are added as they are required.

Active Record validations

# http://guides.rubyonrails.org/active_record_validations_callbacks.html

class SomeClass < ActiveRecord::Base

  # length
@syamilmj
syamilmj / 0_reuse_code.js
Created February 18, 2016 04:45
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@syamilmj
syamilmj / gist:6108795
Created July 29, 2013 23:28
index.php
<?php get_header(); ?>
<?php get_template_part( 'includes/contents/content', 'stream'); ?>
<?php get_template_part( 'includes/contents/content', 'index' ); ?>
<?php get_footer(); ?>
@syamilmj
syamilmj / meta-boxes.php
Created April 24, 2013 22:14
meta-boxes.php
<?php
/**
* Posts & Pages meta boxes
*/
/**
* Main custom meta boxes class
*/
if(!class_exists('AQ_Meta_Boxes')) {
@syamilmj
syamilmj / gist:4442840
Created January 3, 2013 11:30
template-portfolio.php
<?php
/*
Template Name: Portfolio
*/
$column = strtolower($data['aq_portfolio_layout']); //Get number of columns
get_header(); ?>
<div id="content-full-width" class="cf">
@syamilmj
syamilmj / styles.php
Created November 15, 2012 04:25
disable bg patterns
/** line 125 */
background: <?php echo $data['header_bg_color'] ?> url(<?php echo $data['header_bg_img'] ?>);
// Change to:
background: <?php echo $data['header_bg_color'] ?>;
/** line 169 */
@syamilmj
syamilmj / gist:4009718
Created November 4, 2012 01:26
options.css enqueue
if(is_multisite()) {
$uploads = wp_upload_dir();
wp_register_style('options', $uploads['baseurl'] . '/options.css', 'style');
} else {
wp_register_style('options', get_template_directory_uri() . '/css/options.css', 'style');
}