Skip to content

Instantly share code, notes, and snippets.

@JonCook
JonCook / find_reminders.sh
Last active April 23, 2019 23:49
Using find when working with large directory contents
# move all jpg files to a location, the v option is verbose and prints a summary
find . -type f -name '2010*.jpg' -print0 | xargs -0 mv -v --target-directory=/p2sa/stage/realtime/swap/data/
# do a count of files in a directory
find . -type f -name '2013_07*.jp2' | wc -l
@JonCook
JonCook / sed_help.sh
Created October 22, 2018 08:02
Grep files and remove the first part of the results
#Given a line like:
#2018-10-22 02:13:38,510 [pool-1-thread-1] [WARN ] [esac.archive.ssa.simport.file.SohoScienceFile] - File [20181021_0030_c3_512.jpg] being moved to [/ssa/sps/realtime/lasco/c3/2018/10] has size 0
#To get something like:
#File [20181021_0030_c3_512.jpg] being moved to [/ssa/sps/realtime/lasco/c3/2018/10] has size 0.
grep "has size 0" ssa-dl-import.log | sed 's/^.*File/File/'
@JonCook
JonCook / rsync_reminders.sh
Last active October 16, 2018 13:21
rsync a directory of files from local server to remote
rsync -avzhe ssh 2018/ user@mygreat.server.net:/path/where/to/go/to/
@JonCook
JonCook / git_diff_no_space
Created October 13, 2018 17:26
Diff files on different branches ignoring white space using git.
git diff --ignore-space-change temporary-branch master -- jersey/src/main/java/com/baeldung/jersey/server/model/Fruit.java
@JonCook
JonCook / asset_factory.scala
Last active January 3, 2016 02:39
Scala objects with to xml processing and java comparison
package com.cookybear.content.asset.factory
import com.cookybear.content.asset.Asset
import com.cookybear.content.asset.Story
object AssetFactory {
def factory(node: scala.xml.Node): Asset = {
val trimmedNode = scala.xml.Utility.trim(node)
@JonCook
JonCook / match_count.sql
Created December 11, 2012 14:30
useful_sql
select count(*) from fb_match where startdate = 20101211 and competition_id in ('100','101','102','103','104','120')
curl --cert /etc/pki/contentapi.pem --cacert /etc/ca.pem -H "Accept:application/json" -H "X-Candy-Audience:Domestic" -H "X-Candy-Platform:HighWeb" --write-out %{http_code} --silent --output /dev/null https://api.test.bbc.co.uk/content/asset/news/uk-england-16017024
@JonCook
JonCook / svn_changelist
Created December 11, 2012 09:49
SVN snippets
svn changelist CONTENTAPI-630 src/main/resources/config/environment.properties src/main/resources/config/environments/dev.properties src/main/resources/config/environments/sandbox.properties src/main/resources/config/environments/stage.properties src/main/resources/config/environments/live.properties
520 svn status
521 svn diff src/main/resources/config/environment.properties
522 svn status
523 svn commit --changelist CONTENTAPI-630 -m "CONTENTAPI-630 - Temporarily disable XA transations for Content API"
@JonCook
JonCook / encoder.rb
Created December 11, 2012 09:41
Ruby Snippets
require "base64"
def create_big_picture
"<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:a=\"http://www.w3.org/2005/08/addressing\">
<s:Header>
<a:Action s:mustUnderstand=\"1\">http://schemas.news.bbc.co.uk/CPS/Sombrero/ICPSService/ICPSService/GetAsset</a:Action>
<a:MessageID>urn:uuid:5de50599-fc90-4bba-9ff9-ba19fe4a66bc</a:MessageID>
<a:SequenceAcknowledgement>
<a:ReplyTo>http://www.w3.org/2005/08/addressing/anonymous</a:ReplyTo>
</a:SequenceAcknowledgement>
@JonCook
JonCook / HttpResponseVersionProvider.java
Created April 8, 2012 10:24
HTTP Response Version Provider Implementation Class
import javax.ws.rs.core.Response;
import org.apache.cxf.jaxrs.ext.ResponseHandler;
import org.apache.cxf.jaxrs.model.OperationResourceInfo;
import org.apache.cxf.message.Message;
public class HttpResponseVersionProvider implements ResponseHandler {
public static final String VERSION_HEADER = "X-API-Version";