Skip to content

Instantly share code, notes, and snippets.

@Julian-Nash
Julian-Nash / ajax_post.js
Last active February 26, 2018 22:19
Get form data on button click and make an ajax post to the server
// Submit form data to the server
$("#form_id").submit(function(e){
e.preventDefault();
// Create object to send to the server
var data = {
varOne: $("#input_id").val()
}
// ajax setup
@Julian-Nash
Julian-Nash / app.py
Last active February 5, 2018 22:41
Playing with flask-socketio
from flask import Flask, render_template
from flask_socketio import SocketIO, send, emit
app = Flask(__name__)
app.config["SECRET_KEY"] = "secret!"
app.config["DEBUG"] = True
socketio = SocketIO(app)
@app.route("/")
@Julian-Nash
Julian-Nash / html.json
Created February 1, 2018 00:35
Materialize HTML boilerplate snippet for VS Code
{
// Materialize boilerplate
"Materialize Boilerplate": {
"prefix": "materialize",
"body": [
"<!DOCTYPE html>",
"<html lang='en'>",
"<html>\n",
"\t<head>",
"\t\t<title>Materialize Boilerplate</title>",
@Julian-Nash
Julian-Nash / google_dark.icls
Last active January 26, 2018 23:49
Google Dark editor scheme for pycharm
<scheme name="Google Dark" version="142" parent_scheme="Darcula">
<option name="FONT_SCALE" value="1.0" />
<metaInfo>
<property name="created">2018-01-26T23:43:19</property>
<property name="ide">PyCharmCore</property>
<property name="ideVersion">2017.3.3.0.0</property>
<property name="modified">2018-01-26T23:43:29</property>
<property name="originalScheme">google dark</property>
</metaInfo>
<font>
@Julian-Nash
Julian-Nash / darkstyle.py
Last active June 3, 2022 02:55
vs code dark style pygments class
# Version 1 - Not tested
from pygments.style import Style
from pygments.token import (Keyword, Name, Comment, String,
Error, Number, Operator, Generic)
class DarkStyle(Style):
default_style = ""
styles = {
Comment: '#608b4e',
@Julian-Nash
Julian-Nash / testing_pygments.py
Last active January 25, 2018 13:56
Testing pygments python syntax highlighting
from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import HtmlFormatter
code = """numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
evens = [number for number in numbers if number % 2 ==0]
print(evens)
@Julian-Nash
Julian-Nash / .bashrc
Last active January 21, 2018 17:50
.bashrc file - Custom PS1 config
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@Julian-Nash
Julian-Nash / apache_log_parser.py
Created October 6, 2017 18:19 — forked from rahbirul/apache_log_parser.py
Python script for parsing Apache access log
from re import compile, search
from sys import exit
from time import strptime
from datetime import datetime, timedelta, tzinfo
#change this variable to point to the location of the apache access log file
LOG_FILE_LOCATION = '/var/log/httpd/access_log'
LINES_PROCESSED = 0