Skip to content

Instantly share code, notes, and snippets.

View mmacphail's full-sized avatar

Alexandre Fruchaud mmacphail

View GitHub Profile
@prasincs
prasincs / sha1-hash.clj
Created February 15, 2011 08:36
clojure sha1 hash
(defn get-hash [type data]
(.digest (java.security.MessageDigest/getInstance type) (.getBytes data) ))
(defn sha1-hash [data]
(get-hash "sha1" data))
(defn get-hash-str [data-bytes]
(apply str
(map
#(.substring
@michiakig
michiakig / ants.clj
Created July 19, 2011 22:37
Clojure ant sim from Rich Hickey
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
; which can be found in the file CPL.TXT at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
;dimensions of square world
@nicferrier
nicferrier / gist:2277987
Created April 1, 2012 19:34
Clone a git repo if it does not exist, or pull into it if it does exist
#!/bin/sh
REPOSRC=$1
LOCALREPO=$2
# We do it this way so that we can abstract if from just git later on
LOCALREPO_VC_DIR=$LOCALREPO/.git
if [ ! -d $LOCALREPO_VC_DIR ]
then
@akost
akost / convert.sh
Created April 4, 2012 19:06
Bash script for recursive file convertion windows-1251 --> utf-8
#!/bin/bash
# Recursive file convertion windows-1251 --> utf-8
# Place this file in the root of your site, add execute permission and run
# Converts *.php, *.html, *.css, *.js files.
# To add file type by extension, e.g. *.cgi, add '-o -name "*.cgi"' to the find command
find ./ -name "*.php" -o -name "*.html" -o -name "*.css" -o -name "*.js" -type f |
while read file
do
@gmhawash
gmhawash / gist:4043232
Created November 9, 2012 01:54
Reset jenkins password
0. SSH to server
1. Edit /opt/bitnami/apps/jenkins/jenkins_home/config.xml
2. set userSecurity to false: <userSecurity>false</userSecurity>
3. delete
<authorizationStrategy> and <securityRealm>
4. /etc/init.d/bitnami restart
@4ndrej
4ndrej / SSLPoke.java
Last active July 23, 2024 15:12
Test of java SSL / keystore / cert setup. Check the comment #1 for howto.
import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import java.io.*;
/** Establish a SSL connection to a host and port, writes a byte and
* prints the response. See
* http://confluence.atlassian.com/display/JIRA/Connecting+to+SSL+services
*/
public class SSLPoke {
@mtnygard
mtnygard / gist:5615250
Created May 20, 2013 20:29
Query for all data types supported in Datomic.
user> (require '[datomic.api :as d])
nil
user> (def conn (d/connect (doto "datomic:mem://temp" d/create-database)))
#'user/conn
user> (d/q '[:find ?type ?doc :where
[_ :db.install/valueType ?t]
[?t :db/ident ?type]
[?t :db/doc ?doc]]
(d/db conn))
#{[:db.type/long "Fixed integer value type. Same semantics as a Java long: 64 bits wide, two's complement binary representation."]
@welshstew
welshstew / activemq-jmssender.groovy
Created September 12, 2014 04:09
send jms messages to activemq with a neat groovy script
@Grab(group='org.apache.activemq',module = 'activemq-all', version='5.8.0')
import org.apache.activemq.ActiveMQConnectionFactory
import javax.jms.*
def brokerUrl = 'tcp://localhost:61616'
def queue = 'the.soapoverjms.service'
def soapAction = 'urn:sixtree:soapoverjms:dosomething'
def reader = new BufferedReader(new InputStreamReader(System.in))
@smothiki
smothiki / docker engine port
Created February 12, 2015 17:08
docker open on port 2375
cat /etc/init.d/docker
sudo vi /etc/default/docker
add
DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock"
sudo service docker restart
@pdostal
pdostal / create.sh
Created July 16, 2015 19:53
SwapFile
dd if=/dev/zero of=/swapfile bs=1M count=512
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile