Skip to content

Instantly share code, notes, and snippets.

View cesarmiquel's full-sized avatar

Cesar Miquel cesarmiquel

View GitHub Profile
@cesarmiquel
cesarmiquel / copy-to-s3.sh
Last active April 2, 2020 21:13
Upload a file to an Amazon S3 bucket with this bash script (requires OpenSSL and Curl)
#!/bin/bash
#
# Usage: copy-to-s3.sh /full/path/to/the/file.txt /path/in/amazon/fle.txt
#
# Caveat: the path to the file in AWS needs to be URL Encoded (in case there are spaces, etc)
#
# Minimum tweak from this Gist: https://gist.github.com/chrismdp/6c6b6c825b07f680e710
#
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
; Source code to 303 dmeo by 4mat 2020 (http://4matprojects.blogspot.com/2020/03/c64-303.html)
; 303 style by 4mat 2020
; Type sys 49152 to play.
; Written using Dasm assembler. Should be mostly compatible with other assemblers except:
; + The processor line is probably Dasm only unless your assembler handles multiple processors.
; + org might be replaced by * or something else.
; + Some assemblers use !byte or something else instead of .byte, see your docs.
@cesarmiquel
cesarmiquel / find-fragmented-tables.sql
Created January 15, 2020 13:31
List MySQL tables that may need defragmentation
--
-- Source: https://www.thegeekstuff.com/2016/04/mysql-optimize-table/
--
SELECT
table_name
, round(data_length/1024/1024) as data_length_mb\
, round(data_free/1024/1024) as data_free_mb
FROM
information_schema.tables
@cesarmiquel
cesarmiquel / pretty-print-json.md
Created August 23, 2019 16:01
Pretty Print Json File
@cesarmiquel
cesarmiquel / test-seo.php
Created February 4, 2019 21:11
Test <title> and <meta type="description"> tags for SEO purposes against a CSV or regexp
<?php
if (count($argv) != 3) {
print("Usage: $argv[0] [domain] [csv file]\n\n");
exit(0);
}
$domain = $argv[1];
$csv_filename = $argv[2];
@cesarmiquel
cesarmiquel / check-ssl-certificate-expiration.sh
Last active February 3, 2019 22:02
Check the expiration date on the SSL certificate of the given site.
#!/bin/bash
# -----------------------------------------------------------------------------------------
# Check the expiration date on the SSL certificate of the given site. Usate:
#
# $ ./check-ssl-certificate-expiration.sh www.google.com
#
# 🏵 Checking SSL certificate for https://www.google.com...
#
# Expiration date: Apr 9 13:15:00 2019 GMT

You need to have a vt340 terminal for lsix to work. If you are in Ubuntu to:

sudo apt-get install xterm

You need to have a decent font for xterm. You can do this:

  1. Edit ~/.Xresources and put this:
 ! Allow sixel graphics. https://github.com/hackerb9/lsix
@cesarmiquel
cesarmiquel / a_mind_is_born.asm
Created December 17, 2018 05:23 — forked from jblang/a_mind_is_born.asm
A Mind is Born by Linus Akesson
; A Mind is Born by Linus Akesson
; https://linusakesson.net/scene/a-mind-is-born/index.php
; transcribed to 64tass and further commented by J.B. Langston
; important locations after program is copied to zero page
vmptr = $cb ; video matrix
clock = $13 ; global clock lsb - indicates position within bar
clock_msb = $20 ; global clock msb - indicates bar of song
script = $21 ; poke table
@cesarmiquel
cesarmiquel / import-taxonomy.php
Last active October 9, 2018 03:55
Create Drupal 8 taxonomy terms off a YML file. Only two levels are supported.
<?php
use Symfony\Component\Yaml\Yaml;
use Drupal\taxonomy\Entity\Term;
$config = Yaml::parse(file_get_contents(DRUPAL_ROOT . '/sites/default/files/import.yml'));
$vocabulary = $config['vocabulary'];
foreach($config['terms'] as $term => $kids) {
$parent_term = Term::create([
@cesarmiquel
cesarmiquel / rename-tables.php
Created October 2, 2018 20:23
Rename Drupal Tables (remove prefix)
<?php
$cn = \Drupal\Core\Database\Database::getConnection('default', 'default');
// This is prefix you want your tables to remove.
$prefix = 's3cr3t_';
// Read all tables
$result = $cn->query("SHOW TABLES");