Skip to content

Instantly share code, notes, and snippets.

View hyperized's full-sized avatar
🥑
Eating a sandwich

hyperized

🥑
Eating a sandwich
View GitHub Profile
@hyperized
hyperized / gist:6563252
Created September 14, 2013 16:13
A small PHP implementation of Kirupa.coms 3D 'engine'. It does the basic math and lacks commenting.
<?PHP
class ThreeD
{
static public function Transform2Dto3D(array $points, array $axis, $focalLength, $center_x, $center_y)
{
$pointarray = array();
$sx = sin($axis['x']);
$cx = cos($axis['x']);
@hyperized
hyperized / xml_to_array.php
Created November 4, 2013 19:18
Handy XML to Array shortcut
<?php
// Source: http://stackoverflow.com/a/18707244
//convert the XML result into array
$array_data = json_decode(json_encode(simplexml_load_string($data)), true);
?>
---
# Run like: haproxy_drain_backend.yml --extra-vars="webserver=web01"
- hosts: haproxys
serial: 1
gather_facts: true
max_fail_percentage: 0
become: true
vars:
[09:50] myuser@machine:~/$ cat test.yml
---
- hosts: localhost
gather_facts: true
become: true
tasks:
- set_fact:
my_user: myuser
- debug: msg="{{ lookup('pipe', 'id -u ' + my_user) }}"
[09:50] myuser@machine:~/$ ansible-playbook test.yml
- name: assemble configs
assemble:
src: "{{ haproxy_config_path }}/conf.d/"
dest: "{{ haproxy_config_path }}/{{ haproxy_config_file }}"
notify: reload haproxy
---
- hosts: localhost
vars:
hour_block_size: 4
tasks:
# To find the nearest hour within a X (hour_block_size) hour span (nearest neighbor), sort floor
- set_fact:
block_of_hours: "{{ ( ( ansible_date_time.hour | int ) // hour_block_size ) | int }}"
- debug: msg="{{ [ ( block_of_hours | int ) ] | map('extract', range(0, 24, hour_block_size)) | list }}"
[ssh_connection]
# Magic undocumented switch
# - http://grokbase.com/t/gg/ansible-project/161ba72srq/new-ssh-retry-in-ansible-2-0#201601113wgqup2if6iz4b4mjdnnwpfcve
# - https://github.com/ansible/ansible/blob/devel/lib/ansible/constants.py
retries=10
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n

Keybase proof

I hereby claim:

  • I am hyperized on github.
  • I am hyperized (https://keybase.io/hyperized) on keybase.
  • I have a public key ASCc1brEFHgBrQHBStfA2wk3fTjL4rQWmg7T-GVNDeJ1bQo

To claim this, I am signing this object:

How to apt-mirror for Cisofy Lynis

To create our own APT mirror server we've done the following:

$ apt-get install apt-mirror nginx

Put the following in /etc/apt/mirror.list: gist

Put the following in /etc/nginx/sites-enabled/default: gist