Skip to content

Instantly share code, notes, and snippets.

@brandonb927
brandonb927 / osx-for-hackers.sh
Last active November 14, 2024 17:18
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@pognon
pognon / AndroidManifest.xml
Last active March 13, 2022 15:16
NFC Demo
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fr.ippon.mobile.nfcdemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="15" />

Content

Content is created by putting data into a template. In this case, the data is information, and the template is how that information is displayed. Each data and template are also given a title and tags to make them easier to manage and organize. A title makes something easy to identify, and tags make something easy to group.

In this system, the markup languages of JSON is used to describe the data and the template.

Here is an example of a JSON template file named template.json:

{
@christopher-hopper
christopher-hopper / clone-mysql-db.sh
Last active January 15, 2021 17:16
Clone a MySQL database to a new database on the same server without using a dump file. This is much faster than using mysqldump.
#!/bin/bash
DBUSER="root";
DBPASS="";
DBHOST="localhost";
DB_OLD=mydatabase
DB_NEW=clone_mydatabase
DBCONN="--host=${DBHOST} --user=${DBUSER} --password=${DBPASS}";
@jo
jo / js-crypto-libraries.md
Last active November 2, 2024 04:38
List of JavaScript Crypto libraries.

JavaScript Crypto Libraries

List some crypto libraries for JavaScript out there. Might be a bit out dated. Scroll to the bottom.

WebCryptoAPI

http://www.w3.org/TR/WebCryptoAPI/

This specification describes a JavaScript API for performing basic cryptographic operations in web applications, such as hashing, signature generation and verification, and encryption and decryption. Additionally, it describes an API for applications to generate and/or manage the keying material necessary to perform these operations. Uses for this API range from user or service authentication, document or code signing, and the confidentiality and integrity of communications.

@zackjp
zackjp / README.md
Last active November 19, 2019 02:00
Simple Git deploy script for PHP apps

Simple Git deploy script for PHP apps

Usage

SSH into your server then copy deploy.sh, deploy.json, and deploy_post_hook.sh.

git clone https://gist.github.com/8816795.git

Then set your configs in json and run:

@tripflex
tripflex / gist:e964bd36a6d95341859e
Created October 22, 2014 23:28
bash/shell progress function
process_progress() {
[ -z $1 ] && exit 0
PROGRESS=(". " " .. " " ... " " .. " " ." " .. " " ... " " .. ")
COUNTER=0
echo -n "$2 "
while `ps -p $1 > /dev/null`; do
[ $COUNTER -eq 8 ] && COUNTER=0
echo -n "${PROGRESS[$COUNTER]}"
echo -n " Running "
sleep 0.5
@jlefler
jlefler / OptionalSelectionSpinnerAdapter.java
Created October 27, 2014 23:24
Spinner Adapter helper that allows for a first option not in the underlying adapter. I use it to have a "None" option for spinners backed by CursorAdapters. Simplified to use standard styles and based on the answer HRJ provided at http://stackoverflow.com/questions/867518/how-to-make-an-android-spinner-with-initial-text-select-one
package com.joshlefler.statelaw.ui;
import android.content.Context;
import android.database.DataSetObserver;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
@RyanABailey
RyanABailey / js
Created November 24, 2014 05:27
regex password
var password = "Mypassword01";
var regexString = "^((?=.{8,}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*|(?=.{8,}$)(?=.*\d)(?=.*[a-zA-Z])(?=.*[!\u0022#$%&'()*+,./:;⇔?@[\]\^_`{|}~-]).*)";
var regexx = new RegExp(regexString);
if (!regexx.test(password)) {
// password did not match regex
}

Simple Chat Using PHP Socket + HTML5 WebSocket

HTML5's Websocket provides an important feature for establishing a socket connections between web browsers and servers. Once the connection has been established with the server, all the messages are sent directly over a socket rather than usual HTTP response and requests, giving us much faster and persistent communication between a web browser and a server. In this tutorial, let’s create a simple chat system using this technology.

Chat Server using PHP Socket: The Implementation

First, we need to create a Socket server that runs permanently, performs the handshaking, send/receive data from the chat page, and finally handles multiple clients. To this end, we will create a daemon script in PHP. I know what you might be thinking, PHP is mostly used to create dynamic webpages, BUT we can also create background daemons using nothing but PHP. How we do that? Well just follow this steps:

1. Install WebSocket Server

After finished with the Installation of a