Skip to content

Instantly share code, notes, and snippets.

View lsiden's full-sized avatar

Lawrence Siden lsiden

View GitHub Profile
@chrishoerl
chrishoerl / cleanup-gitlab-pipelines.sh
Last active September 13, 2024 13:00
Bulk delete gitlab pipelines older than a given date
#!/bin/bash
# Purpose: Bulk-delete GitLab pipelines older than a given date
# Author: github.com/chrishoerl
# GitLab API: v4
# Requirements: jq must be instaled ($ sudo apt install jq)
# API example: https://gitlab.example.com/api/v4/projects
# API example: https://gitlab.example.com/api/v4/projects/<projectid>/pipelines
#
# NOTE: Script is just a dryrun. To really delete pipelines, simply uncomment line 49 to activate
#
@floatdrop
floatdrop / thoughts.md
Last active January 18, 2021 03:54
Error management in gulp

#Error management in gulp

Sucking at something is the first step to becoming sorta good at something

No one can assure you, that plugins will run smooth in any circumstances (except for tests - they could), so neither should you convince anyone, that your plugin will never break. Only thing, that you could possibly do (if something gone wrong) - is gracefully inform your plugin user, that something went wrong and die.

We are will use this plugin from beginning to demonstrate error management. Suppose you have a task in gulpfile.js that contains this code (we modified it a little bit to be closer to real-usage):

var coffee = require('gulp-coffee');
@alicial
alicial / mock-service-example.js
Last active June 10, 2019 14:26
AngularJS: Setting up a mocked service to use in controller unit tests.
// Mocked Service
angular.module('mock.users', []).
factory('UserService', function($q) {
var userService = {};
userService.get = function() {
return {
id: 8888,
name: "test user"
}
@miyagawa
miyagawa / buildable-git-repo.md
Last active April 17, 2019 14:48
Buildable git repo for CPAN

Buildable, Testable, Installable Git repo for Perl modules

tl;dr We might need a standard build file to build a module from Git repository, especially for the ones using Module::Install or dzil.

The problem

When an author of CPAN module uses an authoring tool that generates build files when shipping them to CPAN, the git repository usually doesn't have enough files to build, test and install the module.

For example, if dzil (Dist::Zilla) is used, the repository only conatains dist.ini and there's no Makefile.PL or Build.PL so standard CPAN installers or Continuous Integration tools don't know how to run tests on it.

@ebouchut
ebouchut / git_ref_to_sha1
Created January 15, 2013 15:44
git SHA1 to reference name conversion (back and forth)
git rev-parse: RefName ======> SHA1
git name-rev: SHA1 <===== RefName
# Convert the reference name HEAD to its corresponding SHA1
git rev-parse HEAD # Assuming for the sake of example that it outputs 1234567
# Convert the SHA1 (1234567) into its reference name (should output HEAD in our example)
git name-rev 1234567
# or else
anonymous
anonymous / Config_heavy.pm
Created January 6, 2012 08:33
My hacks to Config_heavy.pm to get MakeMaker et al to create Makefiles that work on Solaris under OpenCSW
# This file was created by configpm when Perl was built. Any changes
# made to this file will be lost the next time perl is built.
package Config;
use strict;
# use warnings; Pulls in Carp
# use vars pulls in Carp
##
## This file was produced by running the Configure script. It holds all the
## definitions figured out by Configure. Should you modify one of these values,
# modified from https://gist.github.com/763374
module DataMapper
module Resource
def taint! property
self.persistence_state = PersistenceState::Dirty.new(self) \
unless self.persistence_state.kind_of?(PersistenceState::Dirty)
self.persistence_state.original_attributes[properties[property]] = Object.new
end
end
end
@buhrmi
buhrmi / gist:763374
Created January 3, 2011 11:32
A hacky DataMapper monkey patch to mark properties as dirty even if they have not changed
module DataMapper
module Resource
def taint! property
self.persisted_state = State::Dirty.new(self) unless self.persisted_state.kind_of?(State::Dirty)
self.persisted_state.original_attributes[properties[property]] = Object.new
end
end
end
# Example: