Skip to content

Instantly share code, notes, and snippets.

@morsdyce
morsdyce / decrypt-pdf.sh
Created July 10, 2023 08:40 — forked from okvv/decrypt-pdf.sh
bash script to bulk remove password from (pdf) files in current directory using qpdf
#!/usr/bin/env bash
for f in *
do qpdf --password=THE_PASSWORD --decrypt --replace-input $f;
done
# brew install qpdf
# for executable file run: chmod u+x decrypt-pdf.sh
@morsdyce
morsdyce / mockup.md
Last active May 30, 2022 14:50 — forked from adamkleingit/mockup.md
Timer App

Timer App

Please create an app for managing timed tasks.

  1. The user can input a text and click Add
  2. A new task is added with the title, and 00:00 time, and a play button.
  3. Clicking Play will play this task: the timer will start running, and the icon will change to a pause icon. Also - any other running task will be paused.
  4. Clicking Pause will pause the task.
  5. The total time is always updated.
@morsdyce
morsdyce / hoc-template.tsx
Created October 23, 2019 15:36 — forked from rosskevin/hoc-template.tsx
Typescript higher order component (hoc) template
/* variation on https://medium.com/@DanHomola/react-higher-order-components-in-typescript-made-simple-6f9b55691af1 */
import * as React from 'react'
import { wrapDisplayName } from 'recompose'
// Props you want the resulting component to take (besides the props of the wrapped component)
interface ExternalProps {}
// Props the HOC adds to the wrapped component
export interface InjectedProps {}
@morsdyce
morsdyce / reactive2016_lightning_talk.md
Last active March 7, 2019 15:44
Introduction to BDSM - ReactiveConf Lightning talk proposal

This is a proposal for a ⚡lightning talk at the Reactive 2016 conference.

🌟Star this gist if you want to see it on the conference.

Introduction to BDSM

Every day we work with multiple teams to build our products, communication and sync are key factors to deliver your product on time without compromising quality.

In this talk I will introduce BDSM a new mocking tool that will change the way you coordinate between client and server teams minimizing friction allowing each team to work at its own pace while keeping in sync.

@morsdyce
morsdyce / app.js
Created December 22, 2013 16:19
Wordpress style body classes in angular #angularjs #javascript
app.run(function ($rootScope) {
$rootScope.$on('$routeChangeSuccess', function (e, data) {
if (data.$$route && data.$$route.controller) {
$rootScope.controller = data.$$route.controller.toLowerCase().replace('controller', '-controller');
}
})
});
@morsdyce
morsdyce / cors.php
Created September 16, 2013 09:55
PHP CORS request #php #cors #crossdomain
<?php
// Allow from any origin
if (isset($_SERVER['HTTP_ORIGIN'])) {
header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400'); // cache for 1 day
}
// Access-Control headers are received during OPTIONS requests
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
public sealed class PropertiesMustMatchAttribute : ValidationAttribute
{
private const string _defaultErrorMessage = "'{0}' and '{1}' do not match.";
private readonly object _typeId = new object();
public PropertiesMustMatchAttribute(string originalProperty, string confirmProperty)
: base(_defaultErrorMessage)
{
OriginalProperty = originalProperty;
ConfirmProperty = confirmProperty;
public sealed class ValidatePasswordLengthAttribute : ValidationAttribute
{
private const string _defaultErrorMessage = "'{0}' must be at least {1} characters long.";
private readonly int _minCharacters = Membership.Provider.MinRequiredPasswordLength;
public ValidatePasswordLengthAttribute()
: base(_defaultErrorMessage)
{
}
@morsdyce
morsdyce / largestFiles.py
Created August 14, 2017 07:28 — forked from nk9/largestFiles.py
Python script to find the largest files in a git repository.
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Python script to find the largest files in a git repository.
# The general method is based on the script in this blog post:
# http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
#
# The above script worked for me, but was very slow on my 11GB repository. This version has a bunch
# of changes to speed things up to a more reasonable time. It takes less than a minute on repos with 250K objects.
#
@morsdyce
morsdyce / formhandler.cs
Created December 16, 2013 16:11 — forked from anonymous/gist:5311068
Web Api Remove the need for [FromBody] and [FromURI] #asp.net #mvc #webapi
public class FormHandler : DelegatingHandler
{
protected override System.Threading.Tasks.Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
{
if (request.Content != null && request.Content.Headers.ContentType != null &&
request.Content.Headers.ContentType.MediaType == "application/x-www-form-urlencoded")
{
var routeData = request.Properties["MS_HttpRouteData"] as IHttpRouteData;
var form = request.Content.ReadAsFormDataAsync().Result;