Skip to content

Instantly share code, notes, and snippets.

@vlasales
vlasales / ICS.php
Created March 3, 2024 20:17 — forked from jakebellacera/ICS.php
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
@vlasales
vlasales / get_url.php
Created March 6, 2022 18:55
Get content from URL with a header settings
<?php
Actually, upon further reading on the file_get_contents() function:
// Create a stream
$opts = [
"http" => [
"method" => "GET",
"header" => "Accept-language: en\r\n" .
"Cookie: foo=bar\r\n"
]
@vlasales
vlasales / array_recursive_update.php
Created October 28, 2020 17:46
array_walk_recursive() function
<?php
$array = [
'one' => [
'a' => 'one a',
'b' => 'one b',
'c' => 'one c',
],
'two' => [
'd' => 'two d',
'e' => 'two e',
@vlasales
vlasales / latex.vim
Created October 18, 2020 12:25
Disable the md syntax highlighting if it is contained between two $'s
autocmd filetype markdown syn region match start=/\\$\\$/ end=/\\$\\$/
autocmd filetype markdown syn match math '\\$[^$].\{-}\$'
@vlasales
vlasales / yaml-to-xml.php
Created October 16, 2020 12:39 — forked from bzerangue/yaml-to-xml.php
YAML to XML with PHP
<?php
// include Spyc YAML Library for PHP, https://github.com/mustangostang/spyc
include('spyc/Spyc.php');
$node_name = 'data';
$arraylist = Spyc::YAMLLoad('spyc/test.yaml');
function array2xml($array, $node_name) {
$dom = new DOMDocument('1.0', 'UTF-8');
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="page-title.xsl"/>
<xsl:import href="navigation.xsl"/>
<xsl:import href="date-time.xsl"/>
<xsl:output method="html" encoding="utf-8" indent="yes" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*"/>
@vlasales
vlasales / nasa.xsl
Created October 16, 2020 12:18 — forked from bzerangue/nasa.xsl
Converts XML output of the US GSA Social Media API to CSV - http://registry.usa.gov/accounts.xml?agency_id=nasa
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:variable name="delimiter" select="','" />
<!-- define an array containing the fields we are interested in -->
<xsl:variable name="fieldArray">
<field>service_id</field>
<field>account</field>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:variable name="delimiter" select="','" />
<!-- define an array containing the fields we are interested in -->
<xsl:variable name="fieldArray">
<field>date</field>
<field>ny_conventional_gasoline_spot_price_gal</field>
@vlasales
vlasales / trello.md
Created August 7, 2020 21:21 — forked from eric1234/trello.md
Trello Guidelines

A few quick guidelines on my conventions when using Trello. These are not rules. Trello doesn't enforce a structure allowing each project to adapt to it's needs. But this is a good place to start:

Lists

  • Unquoted - Any card being added to the project which is not in the statement of work and not a bug related to work covered by the statement of work goes here. The goal of this list is to avoid scope creep. If scope is being added we want it to be an explicit decision with an explicit cost estimation. The person creating the card should try to estimate the cost (or get someone to do so for them). The client can then choose to move it to the Todo list if they want to increase the scope. If they choose to hold off for now this list provides an excellent idea source for future rounds of development.
  • Todo - These are tasks that need to be done which are not in active development.
  • In Progress - These are tasks that are actively being worked on by a developer. If you are not actively w
@vlasales
vlasales / null_pattern.php
Created August 7, 2020 21:12 — forked from eric1234/null_pattern.php
A null object pattern implemented in PHP
<?php
# Implements a recursive null object pattern.
#
# Implemented as a trait so any object can make it's properties use
# the null pattern without resorting to inheritance.
#
# The goal is so you can pull data off a partially populated object
# without excessive existance checks.
trait NullPattern {