Skip to content

Instantly share code, notes, and snippets.

View samueljon's full-sized avatar

Samúel Jón Gunnarsson samueljon

View GitHub Profile
@samueljon
samueljon / ldap_debug_2.php
Created March 14, 2017 13:26
For debugging ldap connectivity issues in php
<?php
$ldap="host.domain.tld";
$usr="user@domain.tld";
$pwd = 'userpassword';
$debug = true;
// Set debugging
if ($debug) {
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
@samueljon
samueljon / ldap_debug_1.php
Created March 14, 2017 13:21
For debugging Ldap connectivity issues in php
<?php
// Set the ldap server
$ldapurl = "host.domain.tld";
$ldapuser = "user@domain.tld";
$ldappass = 'userpassword';
// Set the debug flag
$debug = true;
// Set debugging
@samueljon
samueljon / .gitconfig
Created January 17, 2017 09:30
.gitconfig and .gitignore_global config examples
[core]
excludesfile = /Users/samueljon/.gitignore_global
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
[user]
name = your name

Keybase proof

I hereby claim:

  • I am samueljon on github.
  • I am samueljon (https://keybase.io/samueljon) on keybase.
  • I have a public key whose fingerprint is BDBD 4772 41E8 D22A 0F00 61C7 0564 BCB7 8181 7004

To claim this, I am signing this object:

@samueljon
samueljon / toggleHT.sh
Last active August 18, 2023 20:05
Disable / Enable HyperThreading cores on runtime - linux
#!/bin/bash
HYPERTHREADING=1
function toggleHyperThreading() {
for CPU in /sys/devices/system/cpu/cpu[0-9]*; do
CPUID=`basename $CPU | cut -b4-`
echo -en "CPU: $CPUID\t"
[ -e $CPU/online ] && echo "1" > $CPU/online
THREAD1=`cat $CPU/topology/thread_siblings_list | cut -f1 -d,`
@samueljon
samueljon / foreachloop.php
Last active May 24, 2016 23:10
example for a friend
<html>
<body>
<?php
$rows = array(
'0' => array( 'name' => 'Herbert', 'phone' => '4312244'),
'1' => array( 'name' => 'Herbert2', 'phone' => '4312266'),
);
?>
<!-- Table -->
<php if(!empty($rows) : ?>
nginx:
image: samueljon/docker-nginx-drupal:develop
ports:
- "8000:80"
- "4430:443"
links:
- db
- php
volumes:
- webroot:/webroot
@samueljon
samueljon / gist:d96e9e741686a5f13488
Last active March 9, 2016 22:46 — forked from tiernano/gist:4344701
IPv6 Firewall rules for a MikroTik router to allow outgoing connections, but block incoming, unless they are responses...
/ipv6 firewall filter
add action=accept chain=input comment="Allow established connections" connection-state=established disabled=no
add action=accept chain=input comment="Allow related connections" connection-state=related disabled=no
add action=accept chain=input comment="Allow UDP" disabled=no protocol=udp
add action=drop chain=input comment="" disabled=no
add action=accept chain=forward comment="Allow any to internet" disabled=no out-interface=sit1
add action=accept chain=forward comment="Allow established connections" connection-state=established disabled=no
add action=accept chain=forward comment="Allow related connections" connection-state=related disabled=no
add action=drop chain=forward comment="" disabled=no
class LsRetailProduct extends LsRetailVorurMigration {
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Import products from LS Retail.');
$this->dependencies = array(
'LsRetailCategoriesTop',
'LsRetailCategoriesSecond',
'LsRetailCategoriesThird',
);
class LsRetailVariant extends LsRetailVorurMigration {
private function getVariantType($fieldName){
switch($fieldName){
//Afbrigði
case 'AFBRIGÐI':
return 'field_nav_afbrigdi';
break;
//Litur
case 'COLOR':