Skip to content

Instantly share code, notes, and snippets.

View Benjaminhu's full-sized avatar
🚀
To infinity and beyond.

Simon Benjámin Benjaminhu

🚀
To infinity and beyond.
View GitHub Profile
@benoit-cty
benoit-cty / slack_backup.py
Last active August 25, 2023 16:32
Script to archive Slack messages from a channel list.
'''
Script to archive Slack messages from a channel list.
You have to create a Slack Bot and invite him to private channels.
View https://github.com/docmarionum1/slack-archive-bot for how to configure your account.
Then provide the bot token to this script with the list of channels.
'''
TOKEN='xoxb-xxxxx-xxxxxx-xxxxxxxxxxx'
channels = {
@lorisleiva
lorisleiva / toSqlWithBindings.php
Last active November 15, 2023 08:54
A little macro to get the SQL from a query builder without the annoying "?".
<?php
use Illuminate\Database\Eloquent\Builder;
Builder::macro('toSqlWithBindings', function () {
$bindings = array_map(
fn ($value) => is_numeric($value) ? $value : "'{$value}'",
$this->getBindings()
);
@mindplay-dk
mindplay-dk / php-upgrades.md
Last active December 28, 2023 16:46
PHP upgrades

Upgrading PHP

Guidelines for upgrading the minimum PHP version requirements of packages and projects.

This isn't meant to be an exhaustive guide to upgrading, but as a checklist for the most important upgrades.

PHP 5.3

The first version to support namespaces - any relevant PHP packages/projects usually have this version as the minimum requirement, so this document won't concern itself with upgrades prior to that.

@parallelo3301
parallelo3301 / utils.sql
Last active January 7, 2024 21:20
PostgreSQL utils
-- v5
----------------------------------------------------------- basic instance info
-- show db version
SELECT version();
-- uptime
SELECT pg_postmaster_start_time();
-- show connections
@estysdesu
estysdesu / create_constraint_if_not_exists.sql
Last active September 13, 2023 00:17
[PostgreSQL: create constraint if not exists] not sure of sql compatibility with other engines #postgres #constraint #sql
// vim: syntax=sql
CREATE OR REPLACE FUNCTION create_constraint_if_not_exists (t_name text, c_name text, constraint_sql text)
RETURNS void
AS
$BODY$
BEGIN
-- Look for our constraint
IF NOT EXISTS (SELECT constraint_name
FROM information_schema.constraint_column_usage
@Werninator
Werninator / php_detect_eol.php
Last active October 3, 2020 17:34
[php] detect EOL type from string
<?php
/**
* Detects the end-of-line character of a string.
* modified version from https://stackoverflow.com/questions/11066857/detect-eol-type-using-php
* @param string $str The string to check.
* @param string $default Default EOL (if not detected).
* @return string The detected EOL, or default one.
*/
function detectEol($str, $default = PHP_EOL) {
@mohammedyunus009
mohammedyunus009 / pdf2htmlEX.sh
Last active August 23, 2023 07:42 — forked from rajeevkannav/pdf2htmlEX.sh
Install CMake, pkg-config,GNU Getopt,GCC,poppler,fontforge,pdf2htmlEX in Ubuntu 16.05
#!/bin/bash
# Ubuntu Developer Script For pdf2htmlEx
# Created by Rajeev Kannav Sharma
# http://rajeevkannav.github.io/
#
#
# Downloads and configures the following:
#
# CMake, pkg-config
# GNU Getopt
@quonic
quonic / scum_sqlite.ps1
Last active September 3, 2022 22:16
For the game SCUM. This sets stats too 5 and skills to 4 for specified character.
#Requires -Module PSSQLite
param(
[Alias('Name', '')]
[string]
$ProfileName
)
<#
Updated for 9/2 patch
Updated by request of Truth91
#>
@spagu
spagu / pre-commit
Last active November 19, 2020 22:57
subversion pre-commit hook for PHP lint, PSR-2 and CSS validation + comments
#!/bin/sh
# SVN PRE-COMMIT HOOK
#
# Requirements:
# - PHP installed ( https://secure.php.net/manual/en/install.php )
# - PHPCS installed ( https://github.com/squizlabs/PHP_CodeSniffer + https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards )
# - csslint installed ( https://github.com/CSSLint/csslint/wiki/command-line-interface )
# - i18n0lint installed ( https://github.com/jwarby/i18n-lint )
Parameters:
InstanceImageIdParameter:
Type: AWS::EC2::Image::Id
Default: 'ami-5055cd3f'
InstanceTypeParameter:
Type: String
Default: t2.micro
InstanceKeyNameParameter:
Type: String
InstanceNameParameter: