Skip to content

Instantly share code, notes, and snippets.

View ProximaB's full-sized avatar
🍀
Focusing

Bartek ProximaB

🍀
Focusing
View GitHub Profile
import os
from PyPDF2 import PdfReader, PdfWriter
def replace_third_page_with_first(dir_path, replacement_file, output_dir):
with open(replacement_file, 'rb') as replacement_pdf_file:
replacement_pdf = PdfReader(replacement_pdf_file)
first_page = replacement_pdf.pages[0]
for filename in os.listdir(dir_path):
if filename.endswith('.pdf'):
/*
This code takes a JSON input string and automatically generates
SQL Server CREATE TABLE statements to make it easier
to convert serialized data into a database schema.
It is not perfect, but should provide a decent starting point when starting
to work with new JSON files.
A blog post with more information can be found at https://bertwagner.com/2018/05/22/converting-json-to-sql-server-create-table-statements/
*/
> foo=$(cat <<EOF
{
"Items":
[
{
"title": "A Midsummer Night's Dream",
"tags":[
"comedy",
"shakespeare",
"play"
package benchmark
import (
"github.com/JumboInteractiveLimited/jsonpath"
"github.com/loov/hrtime/hrtesting"
"github.com/tidwall/gjson"
"io/ioutil"
"strings"
"testing"
)
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
$remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '"
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

using System;
using System.Collections.Generic;
using System.Linq;
namespace ValidatorDekorator
{
class Program
{
static void Main(string[] args)
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PinP.Service
{
public delegate bool Validation();
public class ValidatorDtos
var tmpRes = query.List<object[]>().Select(a => new {
EmployeeId = a[0].ToInt32(),
StudiesModeId = a[1].ToInt32Nullable(),
FormId = a[2].ToInt32Nullable()
}).ToArray();
if (tmpRes != null && tmpRes.Count() > 0)
{
var tmpGroupedRes = tmpRes.GroupBy(a => a.EmployeeId);
//all types or forms for each employee must have value or all of them must not have it - otherwise we throw an exception