Skip to content

Instantly share code, notes, and snippets.

View hassanselim0's full-sized avatar
🏠
Working from Home

Hassan Selim hassanselim0

🏠
Working from Home
View GitHub Profile
@darktable
darktable / MiniJSON.cs
Created November 30, 2011 23:08
Unity3D: MiniJSON Decodes and encodes simple JSON strings. Not intended for use with massive JSON strings, probably < 32k preferred. Handy for parsing JSON from inside Unity3d.
/*
* Copyright (c) 2013 Calvin Rien
*
* Based on the JSON parser by Patrick van Bergen
* http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html
*
* Simplified it so that it doesn't throw exceptions
* and can be used in Unity iPhone with maximum code stripping.
*
* Permission is hereby granted, free of charge, to any person obtaining
@DosAmp
DosAmp / offline_launcher.bat
Created July 20, 2012 11:28
Launch Minecraft in offline mode with user name different from "Player"
@echo off
set username=DosAmp
cd /D %appdata%\.minecraft
start javaw -Xms512m -Xmx1024m -cp bin/lwjgl.jar;bin/lwjgl_util.jar;bin/jinput.jar;bin/minecraft.jar -Djava.library.path="%appdata%\.minecraft\bin\natives" net.minecraft.client.Minecraft "%username%"
@avitsidis
avitsidis / script
Created February 10, 2017 15:24
SSH into mobylinux (docker for windows)
#based on po75558Manuel Patrone comment on https://forums.docker.com/t/how-can-i-ssh-into-the-betas-mobylinuxvm/10991/8
#get a privileged container with access to Docker daemon
docker run --privileged -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker alpine sh
#run a container with full root access to MobyLinuxVM and no seccomp profile (so you can mount stuff)
docker run --net=host --ipc=host --uts=host --pid=host -it --security-opt=seccomp=unconfined --privileged --rm -v /:/host alpine /bin/sh
#switch to host FS
chroot /host
@veuncent
veuncent / docker_debugging.md
Last active February 21, 2024 00:58
Debugging Django apps running in Docker using ptvsd - Visual Studio (Code)

Remote debugging in Docker (for Django apps)

In order to enable debugging for your Django app running in a Docker container, follow these steps using Visual Studio (Code):

  1. Add ptvsd to your requirements.txt file
ptvsd == 4.3.2
  1. To your launch.json, add this:
@Bahus
Bahus / json_schemed_field.py
Last active September 19, 2024 23:53
Django JSONField with Pydantic schema support
from functools import partial
import pydantic
import logging
from django.contrib.postgres.fields import JSONField
from typing import Type, Union, Tuple
from django.core.serializers.json import DjangoJSONEncoder
@djfdyuruiry
djfdyuruiry / README.md
Last active October 8, 2024 04:54
WSL 2 - Enabling systemd

Enable systemd in WSL 2

NOTE: If you have Windows 11 there is now an official way to do this in WSL 2, use it if possible - see MS post here (WINDOWS 11 ONLY)

This guide will enable systemd to run as normal under WSL 2. This will enable services like microk8s, docker and many more to just work during a WSL session. Note: this was tested on Windows 10 Build 2004, running Ubuntu 20.04 LTS in WSL 2.

  • To enable systemd under WSL we require a tool called systemd-genie

  • Copy the contents of install-sg.sh to a new file /tmp/install-sg.sh:

@datocrats-org
datocrats-org / setupDevEnv_workaroundWSL2vhdxLimit.md
Last active July 5, 2024 14:47
Backup and restore WSL2 vhdx, avoid 256GB vhdx limit for docker desktop WSL2 native

Backup and restore WSL2 vhdx, avoid 256GB vhdx limit for docker desktop WSL2 native

Review all steps to view the symptom this Gist addresses, customize a workaround to allow for >256GB Docker pulls safely on Windows, then perform a backup and recovery of the result (export and import). Please provide comments on any failures.

Determine the expected size of the docker-desktop-data volume

  • Get the base image size + additional + all docker volumes using docker system df
  • Add raw uncompressed size for alpine (50MB), docker for your version of windows (700MB) and linux (80MB)

docker system df

@mjgoeke
mjgoeke / memoize.cs
Created December 25, 2020 08:21
C# memoize higher order functions by using tuples
using System;
using System.Collections.Concurrent;
namespace ns
{
//even though this looks like it only takes functions with one input
// by using C# tuple types, one can have any number of inputs (or outputs)
// see example below
public class Memoized<T, TResult>
{
@OrionReed
OrionReed / dom3d.js
Last active November 16, 2024 13:18
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯