Skip to content

Instantly share code, notes, and snippets.

@ksaylor11
ksaylor11 / timestamp.py
Last active October 15, 2018 18:18 — forked from anonymous/gist:5952491
timestamp for today at midnight
#still need to figure out what to do about tzinfo supposedly tzinfo=timezone.utc should work, but still needs to be tested
#currently print at every step just to evaluate what is going on
#need to look into (tzinfo=pytz.utc) and install pytz for some success
import datetime
d=datetime.datetime.now(timezone.utc)
print(d)
dt=d.replace(hour=00,minute=00,second=00)
print(dt)
ts=dt.timestamp(dt)
print(ts)
@ksaylor11
ksaylor11 / socketserver.py
Created August 28, 2014 00:40
basic socket server
'''
Taken from Programming Python.
'''
from socket import *
myHost = ''
myPort = 50007
sockobj = socket(AF_INET, SOCK_STREAM)
sockobj.bind((myHost,myPort))
@ksaylor11
ksaylor11 / socketclient.py
Created August 28, 2014 00:46
basic socket client
'''
Taken from Programming Python
'''
import sys
from socket import *
serverHost = 'localhost'
serverPort = 500007
message = [b'Hello network world']
@ksaylor11
ksaylor11 / embedgist.html
Created August 28, 2014 01:00
demonstrate embedding gists
<!doctype>
<html>
<head>
<title>embedgist</title>
</head>
<body>
<script src="https://gist.github.com/ksaylor11/775f7d5ea92b070f4338.js"></script>
</body>
</html>
@ksaylor11
ksaylor11 / jinja-simple.py
Last active August 29, 2015 14:06
simple jinja code
# straight from the jinja documentation!
from jinja2 import Environment, FileSystemLoader
# configured to load from templates folder
env = Environment(loader=FileSystemLoader('templates')
template = env.get_template('mytemplate.html')
print template.render(the='variables', go='here')
#! /usr/bin/env bash
# Variables
APPENV=local
DBHOST=localhost
DBNAME=dbname
DBUSER=dbuser
DBPASSWD=test123
echo -e "\n--- Mkay, installing now... ---\n"
@ksaylor11
ksaylor11 / default.blade.php
Created April 13, 2018 18:14
Laravel Bootstrap Pagination Customization
@if ($paginator->hasPages())
<ul class="pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="disabled"><span>&laquo;</span></li>
<li class="disabled"><span>&lsaquo;</span></li>
@else
<li><a href="{{ $paginator->toArray()['first_page_url'] }}" rel="prev">&laquo;</a></li>
<li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">&lsaquo;</a></li>
@endif
@ksaylor11
ksaylor11 / select.blade.php
Created April 13, 2018 18:17
Laravel Select Component
<select id="{{{ $element }}}" name="{{{ $element }}}">
@foreach($choices as $choice)
<option value="{{{ $choice->id }}}" @php echo ((!is_null($selectId) && $selectId == $choice->id) ? 'selected': '' ); @endphp>{{{ $choice->name }}}</option>
@endforeach
</select>
@ksaylor11
ksaylor11 / urls.py
Created April 18, 2018 20:02
django url with app as project root
from django.contrib import admin
from django.urls import path, include
from django.conf.urls import url
urlpatterns = [
url(r'^', include('monitor.urls')),
url(r'^admin/', admin.site.urls),
]
@ksaylor11
ksaylor11 / auth.php
Last active April 19, 2018 18:58
Laravel auth.php for API Authentication
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password