Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Salihi prestancedesign

View GitHub Profile
@prestancedesign
prestancedesign / web.clj
Last active May 12, 2021
Ring session authentication with Reitit
View web.clj
(ns authexample.web
(:gen-class)
(:require [buddy.auth :refer [authenticated? throw-unauthorized]]
[buddy.auth.backends.session :refer [session-backend]]
[buddy.auth.middleware :refer [wrap-authentication wrap-authorization]]
[clojure.java.io :as io]
[compojure.response :refer [render]]
[reitit.ring :as ring]
[ring.adapter.jetty :as jetty]
[ring.middleware.params :refer [wrap-params]]
@prestancedesign
prestancedesign / digitalocean-ping.clj
Last active Dec 8, 2020
DigitalOcean datacenter ping with Babashka (Clojure)
View digitalocean-ping.clj
#!/usr/bin/env bb
(require '[babashka.curl :as curl]
'[clojure.java.shell :as shell]
'[clojure.string :as str])
(def url "http://speedtest-ams2.digitalocean.com/")
(def get-endpoints
(let [{:keys [body]} (curl/get url)]
@prestancedesign
prestancedesign / re-frame-click-counter
Last active Dec 8, 2020 — forked from saskali/re-frame-click-counter
Re-frame simple click counter
View re-frame-click-counter
(ns simple.core
(:require [reagent.dom :as reagent]
[re-frame.core :as rf]))
;; -- Domino 1 - Event Dispatch -----------------------------------------------
(defn dispatch-click
[]
(rf/dispatch [:click-count])) ;; send event `:click-count`
View reagent-color-sorting
(ns color-sorting.core
(:require [reagent.core :as reagent]
[reagent.dom :as dom]))
(def colors ["blue" "yellow" "green" "purple" "red"])
(def color-row (reagent/atom ["blue" "yellow" "green"]))
(def sorted-color-row (reagent.ratom/reaction (sort @color-row)))
(defn square [color]
View re-frame-simple-example
(ns simple.core
(:require [reagent.dom :as dom]
[re-frame.core :as rf]
[clojure.string :as str]))
;; A detailed walk-through of this source code is provied in the docs:
;; https://github.com/Day8/re-frame/blob/master/docs/CodeWalkthrough.md
;; -- Domino 1 - Event Dispatch -----------------------------------------------
View re-playground-readme.cljs
(ns instructions.core
(:require [reagent.dom :as dom]
[re-frame.core :as re-frame]))
(defn info []
[:div {:style {:max-width 500}}
[:h1 "re-playground"]
[:p "code is livereloaded.
this right-hand panel has the id 'app'.
to render reagent into this panel, target this element with "
@prestancedesign
prestancedesign / README.md
Last active Dec 8, 2020
A TODO cli with Clojure (Babashka)
View README.md
@prestancedesign
prestancedesign / bitbucket-pipelines.yml
Created Jul 10, 2018 — forked from exileed/bitbucket-pipelines.yml
Bitbucket pipelines test + Ansible deploy script
View bitbucket-pipelines.yml
image: php:7.1-fpm
pipelines:
default:
- step:
caches:
- composer
script:
# Update dependencies
- apt-get update
# Install dependencies
@prestancedesign
prestancedesign / clean-prestashop-db.sql
Last active Jul 3, 2018 — forked from julienbourdeau/clean-prestashop-db.sql
Clean PrestaShop database - Drop old and unless data
View clean-prestashop-db.sql
# Delete all logs
TRUNCATE ps_log;
# Delete old connection data (only used for stats)
# change 2016-02-01 00:00:00 according to you needs
DELETE c, cs
FROM ps_connections c
LEFT JOIN ps_connections_source cs ON (c.id_connections = cs.id_connections)
WHERE c.date_add < '2016-02-01 00:00:00';