Skip to content

Instantly share code, notes, and snippets.

@louis-e
louis-e / UDPSocket.cs
Last active August 27, 2025 22:24 — forked from darkguy2008/UDPSocket.cs
Simple C# UDP server/client in 62 lines
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
namespace UDP
{
public class UDPSocket
{
public Socket _socket;
@GabrielCzar
GabrielCzar / DOCKER_COMPOSE.md
Last active March 16, 2024 21:42
Docker compose samples

Scripts to run specific services

@reven
reven / gist:1b114a6e3a71c665119655ff62068315
Created December 9, 2017 03:43
Recover a USB drive with hidden partitions in Windows 10
I managed to do it with diskpart. What I was missing is the command to create a new partition. So here is a run-down of all the commands I used, step by step.
Beware that when typing select disk 1 (step 4), your disk number may be different. Selecting the incorrect disk might erase your whole computer's main disk drive, losing all your data on it.
I assume you know how to get to the Run prompt since you have arrived at SU. But if not, just press and hold down the Windows key on your keyboard. While still holding the Windows key, press the R key. Voilà! La Run prompt! L'invite de commande!
cmd
diskpart
list disk
select disk 1 (Careful! Choose the correct number here. See note above.)
@igloo15
igloo15 / Server.cs
Created November 7, 2016 15:59
Server class for kestrel web server
using Microsoft.AspNetCore.Hosting;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace WebServer.Main
{
public class Server
@OmegaExtern
OmegaExtern / Singleton Pattern.cs
Created September 13, 2016 18:34
Singleton Pattern in C#.
#region Singleton Pattern
// NOTE: The class is marked as sealed to prevent the inheritance of the class (i.e. use it as base/super class).
internal sealed class Singleton
{
private static readonly object SingletonSyncRoot = new object();
private static volatile Singleton _instanceSingleton;
// NOTE: Default/Parameterless constructor is private to prevent instantiation of the class.
private Singleton()
@tsuharesu
tsuharesu / AddCookiesInterceptor.java
Last active June 8, 2024 07:30
Handle Cookies easily with Retrofit/OkHttp
/**
* This interceptor put all the Cookies in Preferences in the Request.
* Your implementation on how to get the Preferences MAY VARY.
* <p>
* Created by tsuharesu on 4/1/15.
*/
public class AddCookiesInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
@rafaelfoster
rafaelfoster / gen_certificates.sh
Created November 11, 2014 14:24
Generating self signed certificates
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout servername.key -out servername.crt
@shadowbrain
shadowbrain / parse json with sed
Created December 16, 2011 15:32
parse json key:value with sed
## Example: Grab the value for the MYSQL_USER key
User=$( sed -n 's/.*"MYSQL_USER": "\(.*\)",/\1/p' /var/lib/credentials.json )
## Example: Grab the value for the MYSQL_PASSWORD key
Passwd=$( sed -n 's/.*"MYSQL_PASSWORD": "\(.*\)",/\1/p' /var/lib/credentials.json )