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
#Easy one and available on stackoverflow
class Array
def flattify
each_with_object([]) do |element, flattened|
flattened.push *(element.is_a?(Array) ? element.flattify : element)
end
end
end
[1,2,3,4,[1,2,3,4],5].flattify # => [1, 2, 3, 4, 1, 2, 3, 4, 5]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Visavail.js Example: Responsive Layout With Bootstrap</title>
<!-- Bootstrap -->
@ijunaid8989
ijunaid8989 / SneakPeak
Created October 25, 2016 12:12
SneakPeak
As you requested..
from = "2016-10-24 00:00:00+00" to "2016-10-24 00:00:00+00".. and the time was "Monday":["9:0-18:0"]..
You set the interval to 1800(30 minutes.)
It should be getting pictures for 9 hours with 30 minutes range which were going to be 18..
Results it got 13 Images..
#!/usr/bin/env sh
### Download and install megaraidcli for Ubuntu;
FILE="megacli_8.07.14.orig.tar.gz"
LINK="http://hwraid.le-vert.net/ubuntu/sources/$FILE"
wget $LINK -O /tmp/$FILE
(
cd /tmp
users[index]["created_at"] ? DateTime.parse(users[index]["created_at"]).strftime("%A, %d %b %Y %l:%M %p") : "",
users[index]["confirmed_at"] ? DateTime.parse(users[index]["confirmed_at"]).strftime("%A, %d %b %Y %l:%M %p") : "",
users[index]["last_login_at"] ? DateTime.parse(users[index]["last_login_at"]).strftime("%A, %d %b %Y %l:%M %p") : "",
rror] #PID<0.806.0> running EvercamMedia.Endpoint terminated
Server: localhost:4000 (http)
Request: GET /v1/public/cameras?within_distance=26571.402417023513&is_near_to=dublin&geojson=true
** (exit) an exception was raised:
** (FunctionClauseError) no function clause matching in Plug.Conn.resp/3
(plug) lib/plug/conn.ex:455: Plug.Conn.resp(%Plug.Conn{adapter: {Plug.Adapters.Cowboy.Conn, :...}, assigns: %{geojson_cameras: [%Camera{__meta__: #Ecto.Schema.Metadata<:loaded, "cameras">, access_rights: #Ecto.Association.NotLoaded<association :access_rights is not loaded>, cloud_recordings: #Ecto.Association.NotLoaded<association :cloud_recordings is not loaded>, config: %{"auth" => %{"basic" => %{"password" => "aoife", "username" => "aoifemcd"}}, "external_host" => "www.nci.ie", "external_http_port" => 80, "external_rtsp_port" => "", "snapshots" => %{"jpg" => "/ispy/cam2/webcam2.jpg"}}, created_at: #Ecto.DateTime<2014-10-02 13:09:05.795039>, discoverable: true, exid: "gardiner2", id: 3262, is_online: tru
defmodule EvercamMedia.PublicView do
use EvercamMedia.Web, :view
alias EvercamMedia.Util
def render("index.json", %{cameras: cameras, total_pages: total_pages, count: count}) do
%{
cameras: Enum.map(cameras, fn(camera) ->
%{
id: camera.id,
name: camera.name,
defmodule EvercamMedia.PublicController do
use EvercamMedia.Web, :controller
alias EvercamMedia.PublicView
import Ecto.Query
require IEx
@default_distance 1000
@default_offset 0
@default_limit 100
{"ID":68814,"KIND":10,"POSTDATE":"01\/02\/2012","NUMBER":"SI-000539","REFERENCE":null,"MANAGERNAME":"","CURRENCYID":3,"CURRENCYSYMBOL":"\u20AC","FRGAMTVATINC":263.3,"FRGDUEAMT":0,"NEXTCREATEDATE":null}
{
"cloud_recordings": [
{
"frequency": 60,
"storage_duration": 30,
"status": "on",
"schedule": {
"Monday": [
"00:00-23:59"
],