Skip to content

Instantly share code, notes, and snippets.

View bsmirnov's full-sized avatar

Boris Smirnov bsmirnov

View GitHub Profile
# basic pfctl control
# ==
# Related: http://www.OpenBSD.org
# Last update: Tue Dec 28, 2004
# ==
# Note:
# this document is only provided as a basic overview
# for some common pfctl commands and is by no means
# a replacement for the pfctl and pf manual pages.
@bsmirnov
bsmirnov / voucherator.py
Created February 6, 2017 14:18 — forked from gholms/buttond.py
Unifi wireless voucher generator
#!/usr/bin/python -tt
# Copyright 2017 Garrett Holmstrom
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License or (at your
# option) any later version accepted by the Santa Barbara Hackerspace (or
# its successor approved by the Santa Barbara Hackerspace), which shall
# act as a proxy as defined in Section 14 of version 3 of the license.
@bsmirnov
bsmirnov / voucherator.py
Created February 6, 2017 14:18 — forked from gholms/buttond.py
Unifi wireless voucher generator
#!/usr/bin/python -tt
# Copyright 2017 Garrett Holmstrom
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License or (at your
# option) any later version accepted by the Santa Barbara Hackerspace (or
# its successor approved by the Santa Barbara Hackerspace), which shall
# act as a proxy as defined in Section 14 of version 3 of the license.
@bsmirnov
bsmirnov / what-to-wear.js
Created January 15, 2016 02:34 — forked from monkbroc/what-to-wear.js
What to wear
function forecastUrl(apiKey, location) {
var apiUrl = "https://api.forecast.io/forecast";
var excludeFields = "exclude=minutely,hourly";
return apiUrl + "/" + apiKey + "/" + location + "?" + excludeFields;
}
function getForecast(url) {
var got = require("got");
return got(url)
.then(function (response) {
/* Expects month to be in 1-12 index based. */
var monthInformation = function(year, month){
/* Create a date. Usually month in JS is 0-11 index based but here is a hack that can be used to calculate total days in a month */
var date = new Date(year, month, 0);
/* Get the total number of days in a month */
this.totalDays = date.getDate();
/* End day of month. Like Saturday is end of month etc. 0 means Sunday and 6 means Saturday */
this.endDay = date.getDay();
date.setDate(1);
/* Start day of month. Like Saturday is start of month etc. 0 means Sunday and 6 means Saturday */

Awesome PHP

A curated list of amazingly awesome PHP libraries, resources and shiny things.

Categories

  • Composer
  • Composer Related
  • Frameworks
  • Framework Components
@bsmirnov
bsmirnov / README.md
Created August 1, 2012 18:36 — forked from exupero/README.md
Alias a domain to a local port (Mac)

I run a lot of web servers for different projects, all of them on different ports. Generally I start with port 8000 and increment from there as I spin up new servers, but it became tiresome to remember what projects were running on which ports and what the next available port was.

/etc/hosts won't let you specify a port, but a combination of aliasing 127.0.0.1 to 127.0.0.X, forwarding ports from 8000 to 80, and adding the 127.0.0.X IP under an alias in /etc/hosts did work.

This script finds the next available value of X, aliases it with ifconfig, forwards the given port to port 80 with ipfw, and adds a new entry to /etc/hosts that aliases the IP to the domain you want.

Now I can add a server alias with sudo domain-alias funproject 8000, run the web server at 127.0.0.X:8000, and load up http://funproject/ in my browser.

(Because I needed it to work on a Mac, I couldn't use iptables. ipfw seems to work, though its manpage claims it's deprecated and pfctl is the way to go. I wasn't able to figure

@bsmirnov
bsmirnov / block.tpl.php
Created July 14, 2012 20:47 — forked from pixelwhip/block.tpl.php
Modular Stylesheets - Design 4 Drupal
<?php
/**
* @file
* Default theme implementation to display a block.
*
* Available variables:
* - $block->subject: Block title.
* - $content: Block content.
* - $block->module: Module that generated the block.
@bsmirnov
bsmirnov / README
Created May 1, 2012 10:07 — forked from holtzermann17/README
Drupal Migration
These files import ONE database table (users) into Drupal.
Some key issues to note for the record:
* getting the name of the hook right in planetmath.module
(it should be MODULENAME_migrate_api).
* make sure to clear the cache after the module is
imported (drush cc all). This should help identify any
coding errors!
// For 403 @ /admin/settings/customerror
// Title: Access Denied
<?php global $user; // http://www.kinetasystems.com/blog/creating-custom-error-pages-in-drupal ?>
<?php if ($user->uid): ?>
<p>Sorry <?php print $user->name; ?>, you don't have permission to view the page you've just tried to access.</p>
<p>If you feel that you have received this message in error, please
<a href="/about">contact us</a> with specific details so that we may review your access to this web site.</p>
<p>Thanks</p>
<?php else: ?>
<p>This page may be available to clients and registered users only. Please select from one of the other options available to you below.</p>