Skip to content

Instantly share code, notes, and snippets.

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@shandanjay
shandanjay / simplecart_parser.clj
Created May 3, 2016 23:31 — forked from sventech/simplecart_parser.clj
Clojure parser for SimpleCart(js) form POST/GET
(ns webstore.simplecart_parser
(:require [clojure.string :as string]))
;; see github.com/sventech/simplecart-js for tax calculation improvement fork
(def input-params
{"item_quantity_1" "1",
"itemCount" "2",
"item_price_1" "9.99",
"store_name" "Online Store",
"item_name_1" "Awesome Product - MP3",
@shandanjay
shandanjay / slack-user-timezones.php
Created May 17, 2016 04:19 — forked from kasparsd/index.html
Get user timezones using Slack API
<?php
$api_token = 'slack-api-token';
if ( file_exists( 'users.json' ) ) {
$api_users = file_get_contents( 'users.json' );
} else {
$api_users = file_get_contents( 'https://slack.com/api/users.list?token=' . $api_token );
if ( false === $api_users ) {
@shandanjay
shandanjay / chmodr.sh
Created May 21, 2016 01:28 — forked from francisbyrne/chmodr.sh
Recursive chmod script for dirs and/or files
#!/bin/sh
#
# chmodr.sh
#
# author: Francis Byrne
# date: 2011/02/12
#
# Generic Script for recursively setting permissions for directories and files
# to defined or default permissions using chmod.
#
@shandanjay
shandanjay / core.clj
Created July 11, 2016 06:31 — forked from nikolaplejic/core.clj
File upload example in Compojure
(ns fileupload.core
(:use [net.cgrand.enlive-html
:only [deftemplate defsnippet content clone-for
nth-of-type first-child do-> set-attr sniptest at emit*]]
[compojure.core]
[ring.adapter.jetty])
(:require (compojure [route :as route])
(ring.util [response :as response])
(ring.middleware [multipart-params :as mp])
(clojure.contrib [duck-streams :as ds]))
@shandanjay
shandanjay / ffmpeg.md
Created February 6, 2018 09:27 — forked from neilrenicker/ffmpeg.md
How to convert an m4a file to an mp3 using ffmpeg

Convert an m4a file to an mp3 using ffmpeg

  • Install ffmpeg using homebrew:
brew install ffmpeg
  • convert the file:
@shandanjay
shandanjay / import-tar-gz.sh
Created June 20, 2018 06:31 — forked from infusion/import-tar-gz.sh
Import a tar.gz file to MySQL
tar xzOf dump.sql.tar.gz | mysql -u $user -p $database
@shandanjay
shandanjay / gist:e6bb94a7afa3bc04619089e5560886d8
Created September 15, 2018 01:22 — forked from cgmartin/gist:5880732
WebSocket subprotocol and origin validation with HTTP Kit
(ns my.server
(:use org.httpkit.server
[clojure.string :only [split trim lower-case]])
(:import [org.httpkit.server AsyncChannel]))
(defn origin-match? [origin-re req]
(if-let [req-origin (get-in req [:headers "origin"])]
(re-matches origin-re req-origin)))
@shandanjay
shandanjay / ssl_certs.md
Created January 18, 2021 07:21 — forked from tpowellcio/ssl_certs.md
Creating SSL Certs

#Creating Certificates Reference

  1. From a terminal:
openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr
  1. Enter the requested information:
  2. Common Name: The fully-qualified domain name, or URL, you're securing. If you are requesting a Wildcard certificate, add an asterisk (*) to the left of the common name where you want the wildcard, for example *.coolexample.com.
  3. Organization: The legally-registered name for your business. If you are enrolling as an individual, enter the certificate requestor's name.
import re
import PyPDF2
import spacy
class PdfParser():
def __init__(self, file_path):
self.file_path = file_path
def pdf_reader(self) -> str:
content = ''
opener = open(self.file_path, 'rb')