Skip to content

Instantly share code, notes, and snippets.

View Christian-G's full-sized avatar

CG Christian-G

  • Google
  • Amsterdam
View GitHub Profile
@Christian-G
Christian-G / parse_saml_log.rb
Last active April 20, 2017 14:42
SimpleSAMLphp log parser
require 'nokogiri'
class LogfileParser
XPATH_QUERY = "Response[@ID][@Version='2.0']"
SAML_XMLNS = 'urn:oasis:names:tc:SAML:2.0:assertion'
SAMLP_XMLNS = 'urn:oasis:names:tc:SAML:2.0:protocol'
def initialize(path, email)
raise ArgumentError unless File.exists?(path)
@Christian-G
Christian-G / slack_download_profiles.rb
Last active May 27, 2019 02:23
Download profile pictures from Slack, use in combination with slack image scraper: https://gist.github.com/Christian-G/ccad3257e68c4b31d790c4ed66a51761
require 'open-uri'
require 'json'
class Profile
DATA = JSON.parse('<data object>')
end
Profile::DATA.each do |profile|
location = profile.last.sub('https', 'http')
name = profile.first
@Christian-G
Christian-G / sed.sh
Last active February 3, 2017 11:22
grep & sed
# find non UTF8 encoded files
find . -type 'f' -exec file {} \; | grep 'ASCII'
# find
grep -rnw 'app/views/bids' -e "pandoc"
# fix
find '20' -type f -exec gsed -i.bak "s/test/\/media\/Telecom Italia/g" {} \;
find '21' -type f -exec gsed -i.bak "s/Telecom Italia (AWS)\/pandoc-output\/media/\/media\/Telecom Italia (AWS)/g" {} \;
find 'app/views/bids/8' -type f -exec gsed -i.bak "s/Dom-Daniel \/media\/LLC/\/media\/Dom-Daniel LLC/g" {} \;
def find_aaaab(s)
counter_a = 0
s.split("").each do |c|
if c == 'a'
counter_a += 1
elsif (c == 'b' && counter_a >= 4)
return true
else
counter_a = 0
end
@Christian-G
Christian-G / slack_scrape.js
Last active May 14, 2018 15:23
Scrape thumbnails from slack
// 1. Visit https://geant.slack.com/team
// 2. Paste this code in your console
// 3. In console: copy(data)
var store = {}
$('div.member_item').each(function(i, e) {
var el = $(this);
var userimage = el.find('a.member_image').data('original');
var email = el.find('div.expanded_member_details a[title~="Email"]')[0];
if (email !== undefined && userimage.indexOf("?") === -1) {
@Christian-G
Christian-G / docx2md.sh
Last active June 28, 2023 11:35 — forked from jesperronn/docx2md.md
Convert Word documents into Markdown
#!/bin/bash
#
# generate a Markdown version of a word document. Goes in separate folder, since
# images are extracted and converted as well (separate folder avoids naming clashes).
#
# REQUIREMENTS: pandoc
#
#
# with pandoc
# --extract-media=[media folder]

dropdb pulse_dev

dropdb pulse_test

rake db:create

rm db/migrate/*

rails g model Service