Skip to content

Instantly share code, notes, and snippets.

View bsmirnov's full-sized avatar

Boris Smirnov bsmirnov

View GitHub Profile
@bsmirnov
bsmirnov / form-to-json.js
Created January 30, 2012 19:30
Get all form values from page and output as string json object
$(function(){
var txt ="{\n";
$("form :input:not([type=hidden])").each(function(i){
var id = $(this).attr("name");
if($(this).is("select")){
var val = $(this).find("option:selected").text();
}
else {
var val = $(this).val();
@bsmirnov
bsmirnov / gist:2566970
Created May 1, 2012 10:03 — forked from joshuajabbour/gist:864614
Git(Hub) Drupal Project Development Model

Setup

Configure git by using the template for .gitconfig, and adding commands for a Git-aware prompt to .profile.

To clone the repository (the "template" parameter is important):
git clone git@github.com:user/repo.git --template=/PATH/TO/TEMPLATES

Also run (this will set up the repository so a branch can be pushed only while on that branch):
git config remote.origin.push HEAD

// 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>
@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!
@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.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 / gist:4963941
Created February 15, 2013 22:05
uapi-calls-app-manage
[
{
"endpoint": "savvis_uapi_user_subscription_list",
"response": {
"request": "GET /unifiedapi/rest/v1/user/account/subscriptionList HTTP/1.0\r\nContent-Type: application/json\r\nx_savvisdirect_auth_appkey: test\r\nx_savvisdirect_auth_signature: suhwlnsBv3xPDd0vmLCNu3/t0EbsPf2tuq+jhh2ehba+fmaMdrzX1VXIkro+IUSRDXFJCFUCQAlUQxI1S3vf0Y53dY/YvG6FxxyYScmPRzSpRiRqbu+kAGPOFA76xC2u\r\nHost: 10.187.255.79:8080\r\nUser-Agent: Drupal (+http://drupal.org/)\r\nContent-Length: 4\r\n\r\nnull",
"data": "[{\"category\":\"Security & Storage\",\"icon\":\"1d49998cd74f8e38\",\"subscriptionID\":1003663,\"planID\":99,\"planName\":\"Secure Online Backup - 10GB\",\"planPeriodID\":269,\"period\":1,\"periodType\":\"Month(s)\",\"startDate\":1353961271,\"expirationDate\":1361910071,\"status\":\"Active\",\"serviceURL\":null,\"dataCenter\":null,\"services\":[{\"applicationID\":116,\"resourceTypeID\":1000625,\"serviceName\":\"Asigra Cloud Backup\"}],\"serviceStatus\":\"Running\",\"subscriptionName\":\"Secure Online Backup - 10GB (monkey.com)
@bsmirnov
bsmirnov / html--ajax.tpl.php
Created March 26, 2013 10:34
Preprocess for ajax templates
function MYTHEME_preprocess_html(&$vars) {
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
$vars['theme_hook_suggestions'][] = 'html__ajax';
}
}
function MYTHEME_preprocess_page(&$vars) {
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
$vars['theme_hook_suggestions'][] = 'page__ajax';
}

Awesome PHP

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

Categories

  • Composer
  • Composer Related
  • Frameworks
  • Framework Components
Verifying that +bsmirnov is my Bitcoin username. You can send me #bitcoin here: https://onename.io/bsmirnov