Skip to content

Instantly share code, notes, and snippets.

View ijunaid8989's full-sized avatar
πŸ‡΅πŸ‡°
It may have escaped your notice but life isn't fair.

Junaid Farooq ijunaid8989

πŸ‡΅πŸ‡°
It may have escaped your notice but life isn't fair.
  • Islamabad Pakistan
View GitHub Profile
@ijunaid8989
ijunaid8989 / with.ex
Created May 11, 2016 13:39
doing code with "with"
defp validate_params(params) do
with :ok <- validate?("frequency", params["frequency"]),
:ok <- validate?("storage_duration", params["storage_duration"]),
:ok <- validate?("status", params["status"]),
do: :ok
end
def validate?("status", "on"), do: :ok
def validate?("status", "off"), do: :ok
def validate?("status", "on-scheduled"), do: :ok
@ijunaid8989
ijunaid8989 / cond.ex
Created May 11, 2016 13:38
doing code with cond...
defp validate_params(params) do
cond do
!validate?(params["frequency"]) ->
{:invalid, "The parameter 'frequency' isn't valid."}
!validate?(params["storage_duration"]) ->
{:invalid, "The parameter 'storage_duration' isn't valid."}
!cr_status?(params["status"]) ->
{:invalid, "The parameter 'status' isn't valid."}
true ->
{:ok}
Short but not appreciated enough
defp validate_params(params) do
cond do
!validate?(params["frequency"]) ->
{:invalid, "The parameter 'frequency' isn't valid."}
!validate?(params["storage_duration"]) ->
{:invalid, "The parameter 'storage_duration' isn't valid."}
!cr_status?(params["status"]) ->
{:invalid, "The parameter 'status' isn't valid."}
defmodule Password do
@regex_for_mac ~r/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/
def generate(mac_address) do
case check_mac(mac_address) do
{:invalid, message} ->
message
{:ok} ->
password =
fnShowHide = (iCol, oTable) ->
bVis = oTable.fnSettings().aoColumns[iCol].bVisible
oTable.fnSetColumnVis iCol, if bVis then false else true
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>WEATHER API</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet prefetch' href='https://fonts.googleapis.com/css?family=Open+Sans">
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/01_cron.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
# Using similar syntax as the appdeploy pre hooks that is managed by AWS
set -xe
$("#merge_datatables").on 'click', '.action-cam', ->
$('#loading-popup').show()
host = $(this).parents('tr').find('td:nth-child(1)').text()
port = $(this).parents('tr').find('td:nth-child(2)').text()
jpg = $(this).parents('tr').find('td:nth-child(3)').text()
d = {}
d.host = host
d.port = port
d.jpg = jpg
$.ajax
@ijunaid8989
ijunaid8989 / JS Styles
Created December 21, 2015 12:18
Hello!
A little glance on what world is using right now
[WordPress JS Coding Styles](https://make.wordpress.org/core/handbook/best-practices/coding-standards/javascript/)
[JQuery Officials](https://contribute.jquery.org/style-guide/js/)
[Google Coding Style](https://google.github.io/styleguide/javascriptguide.xml)
CREATE TABLE cameras
(
id integer NOT NULL DEFAULT nextval('sq_streams'::regclass),
created_at timestamp with time zone NOT NULL DEFAULT now(),
updated_at timestamp with time zone NOT NULL DEFAULT now(),
exid text NOT NULL,
owner_id integer NOT NULL,
is_public boolean NOT NULL,
config json NOT NULL,
name text NOT NULL,