Skip to content

Instantly share code, notes, and snippets.

View fredyfx's full-sized avatar
💭
With all the power 2.0!

Fredy R. Guibert フレディ fredyfx

💭
With all the power 2.0!
View GitHub Profile
@fredyfx
fredyfx / MockElement.ts
Created July 16, 2020 23:06 — forked from jdhenckel/MockElement.ts
Mock DOM Document and Element in TypeScript for Unit testing in Headless environment.
/*
This can be used in unit tests to simulate a DOM document.
I have implemented the bare minimum. Feel free to add more, or to change my implementation.
Sample Usage:
import 'jasmine';
import { MockElement } from './support/mock-element';
@fredyfx
fredyfx / README.md
Created January 19, 2020 07:00 — forked from hubgit/README.md
Remove metadata from a PDF file, using exiftool and qpdf. Note that embedded objects may still contain metadata.

Anonymising PDFs

PDF metadata

Metadata in PDF files can be stored in at least two places:

  • the Info Dictionary, a limited set of key/value pairs
  • XMP packets, which contain RDF statements expressed as XML

PDF files

@fredyfx
fredyfx / Snake.cs
Created December 3, 2019 18:28 — forked from JerryNixon/Snake.cs
The simple Snake game in C# for the Windows Console
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Threading;
namespace Snake
{
public enum Direction { Stop, Up, Down, Left, Right }
@fredyfx
fredyfx / XMLoutput.cs
Created December 2, 2019 23:56
Since I originally posted my XmlOutput class I’ve received lots of great feedback. I’m happy that many of you have found it useful. I have been using the class myself for most of my xml writing requirements lately (in appropriate scenarios) and I’ve ended up augmenting it a little bit. Nothing major, just a couple of helpful changes. https://imp…
using System;
using System.Collections.Generic;
using System.Xml;
namespace Improve.Framework.Xml
{
public class XmlOutput : IDisposable
{
// The internal XmlDocument that holds the complete structure.
XmlDocument xd = new XmlDocument();
using System;
using System.Security.Cryptography;
using System.Text;
namespace Hash
{
public class Hash
{
public Hash() { }
public static IOrderedQueryable<T> OrderBy<T>(
this IQueryable<T> source,
string property)
{
return ApplyOrder<T>(source, property, "OrderBy");
}
public static IOrderedQueryable<T> OrderByDescending<T>(
this IQueryable<T> source,
string property)
public static void ForEach<T>(this IEnumerable<T> enumeration, Action<T> action)
{
foreach (var item in enumeration)
{
action(item);
}
}
var @switch = new Dictionary<Type, Action> {
{ typeof(Type1), () => ... },
{ typeof(Type2), () => ... },
{ typeof(Type3), () => ... },
};
@switch[typeof(MyType)]();
@fredyfx
fredyfx / resetXcode.sh
Created October 16, 2019 05:47 — forked from maciekish/resetXcode.sh
Reset Xcode. Clean, clear module cache, Derived Data and Xcode Caches. You can thank me later.
#!/bin/bash
killall Xcode
xcrun -k
xcodebuild -alltargets clean
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Caches/com.apple.dt.Xcode/*
open /Applications/Xcode.app
@fredyfx
fredyfx / Common-Currency.json
Created May 11, 2019 00:37 — forked from ksafranski/Common-Currency.json
Common Currency Codes in JSON
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},