Skip to content

Instantly share code, notes, and snippets.

View donjordano's full-sized avatar
🏠
WFH

Ivan Yordanov donjordano

🏠
WFH
View GitHub Profile
@divinity76
divinity76 / ubu_1804_amdgpu_compute_mode_linux.php
Last active February 8, 2024 19:07
sets "compute mode" on AMD GPU's in linux
#!/usr/bin/env php
<?php
declare(strict_types = 1);
// this does NOT work on my ubuntu 20.04, look at the other files for a 20.04 version
if (posix_geteuid () !== 0) {
die ( "error: this script requires root privileges, re-run it as root." );
}
$amdgpu_dir = '/sys/bus/pci/drivers/amdgpu';
$dirs = array_filter ( array_map ( 'trim', glob ( $amdgpu_dir.DIRECTORY_SEPARATOR.'*', GLOB_NOSORT | GLOB_ONLYDIR | GLOB_MARK ) ), function (string $str) {
return (is_writable ( $str."power_dpm_force_performance_level" ) && is_writable ( $str.'pp_compute_power_profile' ));
# When using RN in combination with Cocoapods, a lot of
# things are broken. These are the fixes we had to append
# to our Podfile when upgrading to ReactNative@0.55.3.
#
# WARNING: Check those line numbers when you're on a different version!
def change_lines_in_file(file_path, &change)
print "Fixing #{file_path}...\n"
contents = []
@lokhman
lokhman / ubuntu-hardening.md
Last active April 23, 2024 09:05
List of things for hardening Ubuntu

WARNING

May contain out of date information. Check the comments below!

The list of actions listed below was taken mostly from Book Of Zeus with minor modifications and did the job well for Ubuntu version, which was available at that moment (May 2016). This gist was created for internal use and was never meant to be discovered by the web, although Google managed to find and index this page, which was a great surprise for me. Please check the original source for the updated information (links are provided in most of the sections), and read the comments below: they provide more details about the usage experience.

System Updates

http://bookofzeus.com/harden-ubuntu/initial-setup/system-updates/

Keeping the system updated is vital before starting anything on your system. This will prevent people to use known vulnerabilities to enter in your system.

@ericdke
ericdke / permutations.swift
Created January 24, 2016 00:35
Swift: Heap's algorithm with Generics
public extension CollectionType {
var permutations: [[Generator.Element]] {
func permute<C: CollectionType>(items: C) -> [[C.Generator.Element]] {
var scratch = Array(items) // This is a scratch space for Heap's algorithm
var result: [[C.Generator.Element]] = [] // This will accumulate our result
// Heap's algorithm
func heap(n: Int) {
if n == 1 {
result.append(scratch)
return