Skip to content

Instantly share code, notes, and snippets.

Avatar

Nigel James njames

View GitHub Profile
@njames
njames / delete_branches_older_than.sh
Last active May 30, 2023 01:02 — forked from AvnerCohen/delete_branches_older_than.sh
Script to delete branches older than 6 months old, ignore local vs remote errors.
View delete_branches_older_than.sh
#!/bin/sh
ECHO='echo '
for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'main$\|develop$'); do
if ! ( [[ -f "$branch" ]] || [[ -d "$branch" ]] ) && [[ "$(git log $branch --since "1 month ago" | wc -l)" -eq 0 ]]; then
if [[ "$DRY_RUN" = "false" ]]; then
ECHO=""
fi
local_branch_name=$(echo "$branch" | sed 's/remotes\/origin\///')
$ECHO git branch -d "${local_branch_name}"
@njames
njames / dslr-webcam.md
Created January 18, 2023 05:18 — forked from jessarcher/dslr-webcam.md
Using my Canon 70D DSLR camera as a web cam on Linux
View dslr-webcam.md

You'll need:

  1. Video 4 Linux loopback device kernel module (v4l2loopback) - Source: https://github.com/umlaeute/v4l2loopback (You might find builds in your distro's repos - I'm using Fedora so had to build it myself using https://github.com/danielkza/v4l2loopback-fedora/)
  2. gPhoto2 - this is what allows you to access your cameras live feed over USB - this was available in Fedora's repos.
  3. GStreamer or ffmpeg - this is what lets you stream the output from gPhoto2 into the loopback device.

It's been a little while since I set it all up so I can't remember all of the installation details, which will probably be different for your distro anyway unless you're using Fedora. Apologies if I have forgotten something as wel.

Running the stream

@njames
njames / get_caller_id.abap
Created August 14, 2019 05:03
example determining user from service now
View get_caller_id.abap
method get_caller_id.
data: uri type string
, body type string
, token type string
, agreements type string
, lo_response type ref to if_rest_entity
* , parser TYPE REF TO /ui5/cl_json_parser
, user type ref to data
, user_row type ref to data
@njames
njames / get_assignement_group.abap
Created August 14, 2019 05:02
example code for integrating into service now from fiori
View get_assignement_group.abap
method get_assignment_group.
data: uri type string
, group type ref to data
, group_row type ref to data
, group_name type string
, response type ref to if_rest_entity
.
* read the group name from config * hard coded from now
@njames
njames / copy_structure.abap
Created December 13, 2013 05:25
copy from one structure to another copy of the same structure and only overwrite the new items
View copy_structure.abap
METHOD copy_structure .
* parameters
* i_new type any
* i_old type any
* final - changing type any
* copy by component only if the new value is populated else take
* the existing component
DATA: _componentno TYPE i VALUE 0
.
@njames
njames / Types_include.abap
Created May 23, 2013 03:11
Example of including a structure with a types command in ABAP
View Types_include.abap
TYPES: BEGIN OF line,
date_from TYPE d,
time_from TYPE t,
date_to TYPE d,
time_to TYPE t.
INCLUDE TYPE crmst_date_btil.
TYPES: END OF line.
CREATE DATA rv_sample TYPE line.
@njames
njames / ABAP_compare_set.abap
Last active December 17, 2015 15:29
Two ways of comparing a set of values in ABAP.
View ABAP_compare_set.abap
METHOD ENABLE_OCA_BUTTONS.
DATA: lv_status TYPE j_estat
, lo_current TYPE REF TO if_bol_bo_property_access
, table_rows TYPE i
.
FIELD-SYMBOLS: <status> type RSDSSELOPT.
* default condition to false and change if in correct status
View z_hello_datetime.abap
REPORT z_hello_datetime.
data:
dt type REF TO zcl_datetime
, fs type string
, ts type timestamp
.
get time STAMP FIELD ts.
@njames
njames / size_bol_collection.abap
Last active December 17, 2015 01:48
Determine the size of a BOL collection
View size_bol_collection.abap
* the last two buttons are displayed only if there is data in the table
lv_btn_enabled = abap_true.
lv_col_wrapper = typed_context->builactivity->collection_wrapper.
IF lv_col_wrapper->size( ) > 0.
lv_btn_enabled = abap_false.
ENDIF.