Skip to content

Instantly share code, notes, and snippets.

function hide(selector) { $(selector).setAttribute('style','display:none')}
function remove(selector) { $(selector).remove()}
function remove_class(selector) { $(selector).setAttribute('class','')}
function move_left(count)
{
var eventObj = document.createEvent("Events");
eventObj.initEvent("keydown", true, true);
eventObj.which = 37; // left key
for (i=0; i < count ; i++) {
@DinisCruz
DinisCruz / Linked-in-post.md
Last active March 7, 2024 15:36
make LinkedIn Post page printer friendly

"Creating a 'Print-friendly' version of a LinkedIn post that can be shared as a PDF or PNG" - How hard could it be, right?

TL;DR: Use the JavaScript code from this GIST: https://gist.github.com/DinisCruz/d5e4bb4d8a6dcd7b25e31d160c747f1e

Unless I'm missing something very obvious, there isn't an easy way to create a PDF or a PNG image from a LinkedIn post (I need posts in this format so that I can easily share them on WhatsApp, Discord, or Slack).

As an example, I wanted to share the daily poem that I posted today (see https://www.linkedin.com/posts/diniscruz_here-is-a-poem-for-the-7th-of-march-2024-activity-7171459601492602880-Tkzs) with my family, which includes some members who are not on LinkedIn.

What I wanted was to create something like what you can see in pic2, i.e., a reasonably formatted pdf/png that allows for the easy reading of the post's content (and images).

@DinisCruz
DinisCruz / 78.direct-browser-scripting.coffee
Last active May 6, 2023 00:23
chrome-remote-interface test scripts
if (iframe1.contentWindow.location.href.indexOf 'google') is -1
iframe1.src='https://www.google.com'
else
document = iframe1.contentDocument
document.getElementsByName('q')[0].value = 'Node WebKit REPL'
document.getElementsByName('btnG')[0].click()
@DinisCruz
DinisCruz / 87-prettify-url-on-pop-under-window.js
Last active May 6, 2023 00:09
Misc Chrome extensions code snippets (to add to helper doc)
url = 'http://127.0.0.1:4444/wd/hub/sessions'
options = { active:true, windowType:"normal", currentWindow: true }
chrome.tabs.query(options,function(tabs)
{
tabId = tabs[0].id
console.log(tabId)
chrome.tabs.update(tabId, {url: url})
chrome.tabs.executeScript(tabId, {file:'bower_components/jquery/dist/jquery.min.js'}, function()
@DinisCruz
DinisCruz / gist:3185313
Created July 26, 2012 23:59
VisualStudio VSIX: Adding an item to the ErrorList
var vsixPackage = O2_FluentSharp_VSIXPackage.vsixPackage; // this is a reference to an Package object
var ivsSolution = (IVsSolution)Package.GetGlobalService(typeof(IVsSolution));
var dte = (EnvDTE80.DTE2)Package.GetGlobalService(typeof(EnvDTE.DTE));
var errorListProvider = new ErrorListProvider(vsixPackage);
var errorText = "this is a test item";
var errorCategory = TaskErrorCategory.Error;
//Get first project details
var proj = dte.Solution.Projects.Item(1);
@DinisCruz
DinisCruz / consume md5 files.cs
Last active October 1, 2021 05:11
H2 script - Generate Small MD5 Rainbow Table
var topPanel = "{name}".popupWindow(700,200);
//var topPanel = panel.clear().add_Panel();
"Loading data".info();
var baseFolder = @"C:\Users\o2\AppData\Roaming\OWASP_O2_Platform_5.3\8_12_2013\MD5_Hashes";
var md5HashesFile = baseFolder.pathCombine("(10x numbers - 2x length) M5_for_10_chars_with_2_depth.txt");
var md5Hashes = md5HashesFile.fileContents();
var mappings = new Dictionary<string,string>();
foreach(var line in md5Hashes.lines())
{
@DinisCruz
DinisCruz / Vulnerability_Weak_Crypto.java
Created September 4, 2016 15:43
Java test that confirms how Random().nextInt() values can be predicted
import org.junit.Test;
import java.util.ArrayList;
import java.util.Random;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class Vulnerability_Weak_Crypto {
/*<!--<method>
<class>com.foo.MyThing</class>
<name>doStuff</name>
<parameter-types>
<class>java.lang.String</class>
<class>java.util.Iterator</class>
</parameter-types>
</method>()-->
*/
def groovyExecution = new GroovyExecution();
import java.io.IOException;
public class PoC_XMLGenerator
{
public static void main(String[] args) throws IOException
{
String process = "open";
String arguments = "/Applications/Calculator.app";
@DinisCruz
DinisCruz / javap-test.java
Created September 5, 2016 10:04
Here is an experiment with javap to extract the methods programatically. It looks like javassit will be a better way to do this (specially since it is native)
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* Created by diniscruz on 01/09/2016.
*/
public class JavapHelper {