Skip to content

Instantly share code, notes, and snippets.

@timiles
timiles / hidefromtimeline.js
Last active October 20, 2023 21:12
Hide from timeline: javascript to hide all displayed posts from your facebook timeline. Doesn't delete anything, only hides from timeline.
/*---------------------
INSTRUCTIONS:
1. open https://www.facebook.com/me
2. run script*
3. refresh if necessary, goto 2.
* to save as bookmarklet, create new bookmark in your browser of choice -
Name: "hide from timeline"
URL: "javascript: <content of gist below>"
-----------------------*/
@timiles
timiles / Rename-ItemsByDateTaken.ps1
Last active July 3, 2023 18:49
PowerShell script to prefix files by Date Taken from EXIF data
function Get-DateTakenFromExifData {
param([String] $filePath)
try {
$imgData = New-Object System.Drawing.Bitmap($filePath)
try {
[byte[]]$dateTakenExifData = $imgData.GetPropertyItem(36867).Value
[string]$dateString = [System.Text.Encoding]::ASCII.GetString($dateTakenExifData)
return [datetime]::ParseExact($dateString, "yyyy:MM:dd HH:mm:ss`0", $null)
}
@timiles
timiles / Ovod.srt
Created January 9, 2023 18:20
Ovod (Овод) / The Gadfly (1955) - original subtitles - slightly reformatted to improve results from Google translate
1
00:01:59,640 --> 00:02:02,000
Там наша родина, друзья мои.
2
00:02:06,400 --> 00:02:08,320
Сквозь бури и ветер,
3
00:02:09,760 --> 00:02:12,880
@timiles
timiles / objectUtils.ts
Last active June 6, 2022 15:18
get / set properties using dot notation
// property can have dot notation, eg 'parent.child.value'
export const getPropertyValue = (obj: any, property: string) =>
property.split('.').reduce((a, b) => (a ? a[b] : undefined), obj);
// property can have dot notation, eg 'parent.child.value'
export const setPropertyValue = (obj: any, property: string, value: any) => {
const keys = property.split('.');
const lastKey = keys.pop()!;
let currentObj = obj;
keys.forEach((key) => {
@timiles
timiles / AppState.tsx
Created April 29, 2022 11:25
Global app state using React Context
import { createContext, PropsWithChildren, useContext, useState } from 'react';
interface IContext {
getValue: <T>(key: string) => T | undefined;
setValue: <T>(key: string, value: T) => void;
}
const AppStateContext = createContext<IContext | undefined>(undefined);
const AppStateContextProvider = ({ children }: PropsWithChildren<{}>) => {
@timiles
timiles / fixes.reg
Created March 1, 2022 14:29
Windows 11 registry fixes
; Disable "Show more options" context menu
[HKEY_CURRENT_USER\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32]
@=""
; Disable web search from start menu
[HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Windows\Explorer]
"DisableSearchBoxSuggestions"=dword:00000001
@timiles
timiles / gist:4445456
Last active August 5, 2021 15:49
Mock HttpContext.Current.Request.Headers. This is ugly but it works. credit: http://bigjimindc.blogspot.co.uk/2007/07/ms-kb928365-aspnet-requestheadersadd.html
HttpContext.Current = new HttpContext(
new HttpRequest("", "http://tempuri.org", ""), new HttpResponse(new StringWriter()));
NameValueCollection headers = HttpContext.Current.Request.Headers;
Type t = headers.GetType();
const BindingFlags nonPublicInstanceMethod = BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance;
t.InvokeMember("MakeReadWrite", nonPublicInstanceMethod, null, headers, null);
t.InvokeMember("InvalidateCachedArrays", nonPublicInstanceMethod, null, headers, null);
@timiles
timiles / SecretSanta.cs
Last active November 18, 2020 14:20
Generate and send random Secret Santa assignments via email
void Main()
{
var santas = new[]
{
// TODO: Fill out names and email addresses of all participants
new Santa("Person 1", "person1@example.com"),
new Santa("Person 2", "person2@example.com"),
new Santa("Person 3", "person3@example.com"),
new Santa("Person 4", "person4@example.com"),
};
@timiles
timiles / Rename-ItemsByDateTimeFromFileNameOrExifData.ps1
Last active September 20, 2020 15:55
PowerShell script to prefix files by DateTime from file name or Date Taken from EXIF data
function Get-DateTakenFromExifData {
param([String] $filePath)
try {
$imgData = New-Object System.Drawing.Bitmap($filePath)
try {
[Byte[]]$dateTakenExifData = $imgData.GetPropertyItem(36867).Value
[String]$dateString = [System.Text.Encoding]::ASCII.GetString($dateTakenExifData)
return [DateTime]::ParseExact($dateString, "yyyy:MM:dd HH:mm:ss`0", $null)
}
@timiles
timiles / RequestLogger.cs
Last active June 7, 2019 19:12
RequestLogger
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Text;
using System.Web;
using Microsoft.WindowsAzure.ServiceRuntime;