This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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 --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") : "", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"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} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cloud_recordings": [ | |
{ | |
"frequency": 60, | |
"storage_duration": 30, | |
"status": "on", | |
"schedule": { | |
"Monday": [ | |
"00:00-23:59" | |
], |