Skip to content

Instantly share code, notes, and snippets.

View Vitexus's full-sized avatar
πŸ€–
Coding as usual

Cybervitexus Vitexus

πŸ€–
Coding as usual
View GitHub Profile
@cjsaylor
cjsaylor / sample_class.php
Created November 22, 2012 14:36
Convenient PHPUnit mocking of Singleton Classes
<?php
class Sample {
public __construct() {
}
public function sayHello($name) {
return Someclass::getInstance()->hello($name);
}
@samdoran
samdoran / luks-encrypt-in-place.sh
Last active August 13, 2024 19:14
Encrypt a physical volume using LUKS without erasing the drive.
#!/bin/bash
# Encrypt existing hard drive in place.
# Requires a second physical drive to temporarily store data. This drive will be erased.
# This script is meant to be run on Clonezilla 1.2.9-19 or later.
# The cryptsetup syntax is different in Clonezilla than in Red Hat.
# --- Variables --- #
@ludo237
ludo237 / .htaccess
Last active December 11, 2024 14:30
The ultimate .htaccess file. Please feel free to fork it, edit it and let me know what do you think about it.
# Apache configuration file
# httpd.apache.org/docs/2.2/mod/quickreference.html
# Note .htaccess files are an overhead, this logic should be in your Apache
# config if possible: httpd.apache.org/docs/2.2/howto/htaccess.html
# Techniques in here adapted from all over, including:
# Kroc Camen: camendesign.com/.htaccess
# perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
# Sample .htaccess file of CMS MODx: modxcms.com
# This is the free sample of .htaccess from 6GO s.r.l.
# @author Claudio Ludovico Panetta (@Ludo237)
@AlexPashley
AlexPashley / replace.php
Last active January 25, 2023 23:40
PHP: function that will replace textual URLs with HTML links, this also works for email addresses.
<?php
function replace_links( $text )
{
$text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);
$ret = ' ' . $text;
// Replace Links with http://
$ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\" rel=\"nofollow\">\\2</a>", $ret);
@tautrimas
tautrimas / XmlToArrayParser
Last active February 24, 2022 21:17
Very good XML to PHP array converter found at http://outlandish.com/blog/xml-to-json/
<?php
/**
* Class XmlToArrayParser
*/
class XmlToArrayParser
{
/**
* @param SimpleXMLElement $xml
* @param array $options
@hofmannsven
hofmannsven / README.md
Last active April 1, 2025 06:51
Git CLI Cheatsheet
@shirou
shirou / ssh_keyscan.yml
Last active March 6, 2025 06:47
run ssh-keyscan to add keys to known_hosts. This is a playbook for ansible
---
- hosts: all
gather_facts: no
sudo: no
tasks:
- name: run ssh-keyscan to add keys to known_hosts
local_action: shell ssh-keyscan {{ ansible_ssh_host }} >> ~/.ssh/known_hosts
@rxaviers
rxaviers / gist:7360908
Last active April 25, 2025 09:32
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: πŸ˜„ :smile: πŸ˜† :laughing:
😊 :blush: πŸ˜ƒ :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
πŸ˜† :satisfied: 😁 :grin: πŸ˜‰ :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: πŸ˜€ :grinning:
πŸ˜— :kissing: πŸ˜™ :kissing_smiling_eyes: πŸ˜› :stuck_out_tongue:
@tott
tott / ip_in_range.php
Created November 27, 2013 22:46
php check if IP is in given network range
/**
* Check if a given ip is in a network
* @param string $ip IP to check in IPV4 format eg. 127.0.0.1
* @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed
* @return boolean true if the ip is in this range / false if not.
*/
function ip_in_range( $ip, $range ) {
if ( strpos( $range, '/' ) == false ) {
$range .= '/32';
}
@betweenbrain
betweenbrain / gist:7798873
Created December 5, 2013 01:47
Disable VT-X in Vagrantfile
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--hwvirtex", "off"]
end