Skip to content

Instantly share code, notes, and snippets.

<?php
class Dep {
protected $name;
protected $dependencies = [];
public function __construct($name) {
$this->name = $name;
}
@grom358
grom358 / generate_dep.php
Last active August 29, 2015 14:11
Generate dependency listing for install profile
<?php
/**
* Root directory of Drupal installation.
*/
define('DRUPAL_ROOT', getcwd());
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
@grom358
grom358 / indexer.md
Last active August 29, 2015 14:19
Index Features
  • Query what source code files exist in the codebase
  • Query what classes/traits/interfaces exist. eg. $index->getClasses() returns fully qualified list of class names
  • Query what functions exist. eg. $index->getFunctions() returns fully qualified list of function names
  • On a class/trait/interface can find what methods/properties/constants exist
  • On a class/interface can inspect the parent class/interface
  • On a class/trait inspect what interfaces are implemented
  • For a class find subclasses
  • For a trait find trait usages
  • For an interface find class/traits that implement the interface
  • For an interface find interfaces which extend it
@grom358
grom358 / obj_to_array.php
Last active August 29, 2015 14:19
Convert PHP object to array
<?php
function object_to_array($data, $visited = array()) {
if (!is_array($data) and !is_object($data)) {
return $data;
}
if (is_object($data)) {
// Detect object cycles, overwise recursion occurs.
$hash = spl_object_hash($data);
if (isset($visited[$hash])) {
return '** RECURSION **';
;(function($) {
function Tooltip(elem, conf) {
// Create tooltip
var tooltip = $('<div></div>')
.addClass(conf.className)
.html(elem.attr('title'))
.insertAfter(elem);
tooltip.hide();
// Remove the browser tooltip
.tooltip {
position: absolute;
padding: 10px 13px;
z-index: 2;
max-width: 600px;
color: #303030;
background-color: #f5f5b5;
border: 1px solid #deca7e;
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
"sync"
)
@grom358
grom358 / ldap.php
Last active December 4, 2015 02:44
<?php
class LDAP_Connection {
protected $ds;
protected $baseDN;
protected $hostname;
protected $port;
protected $binaryFields;
private $isConnected;
public function __construct($config = null) {
create keyspace weather with replication = {'class' : 'NetworkTopologyStrategy', 'AWS_VPC_US_EAST_1' : 3};
use weather;
create table city (cityid int, avg_tmp float, description text, primary key (cityid));
insert into city (cityid, avg_tmp, description) values (1,25.5,'Mild weather');
insert into city (cityid, avg_tmp, description) values (2,3,'Cold weather');
create table forecast(cityid int,forecast_date timestamp,humidity float,chanceofrain float,wind float,feelslike int, centigrade int, primary key (cityid,forecast_date));
insert into forecast(cityid,forecast_date,humidity,chanceofrain,wind,feelslike,centigrade) values (1,'2013-12-10',0.76,0.1,10,8,8);
insert into forecast(cityid,forecast_date,humidity,chanceofrain,wind,feelslike,centigrade) values (1,'2013-12-11',0.90,0.3,12,4,4);
insert into forecast(cityid,forecast_date,humidity,chanceofrain,wind,feelslike,centigrade) values (1,'2013-12-12',0.68,0.2,6,3,3);
insert into forecast(cityid,forecast_date,humidity,chanceofrain,wind,feelslike,centigrade) valu
@grom358
grom358 / runtime.c
Created July 31, 2025 12:07
Random foundation layer C
typedef struct {
size_t len;
const char* ptr;
} StringView;
void libc_panic(int code, const char* file_name, const char* function_name, int line_no) {
fprintf(stderr, "FATAL ERROR at %s:%s:%d - %s\n",
file_name, function_name, line_no, strerror(code));
exit(EXIT_FAILURE);
}