Skip to content

Instantly share code, notes, and snippets.

View avmesquita's full-sized avatar

Andre Mesquita avmesquita

View GitHub Profile
@aspose-com-gists
aspose-com-gists / generate-pdf-thumbnail-all-pages.cs
Last active January 12, 2024 13:07
Generate Thumbnails for PDF Files in C#
// Open document
Document pdfDocument = new Document("file.pdf");
// Loop through pages
for (int pageCount = 1; pageCount <= pdfDocument.Pages.Count; pageCount++)
{
// Create stream for each image
using (FileStream imageStream = new FileStream("Thumbanils_" + pageCount + ".jpg", FileMode.Create))
{
// Create Resolution object
@lizzies
lizzies / add-wordpress-settings-page.php
Created February 20, 2022 16:55 — forked from DavidWells/add-wordpress-settings-page.php
WordPress :: Add Settings Page with All Fields
<?php
/*
Plugin Name: Homepage Settings for BigBang
Plugin URI: http://www.inboundnow.com/
Description: Adds additional functionality to the big bang theme.
Author: David Wells
Author URI: http://www.inboundnow.com
*/
// Specify Hooks/Filters
@dherges
dherges / http-client-feature.service.ts
Last active March 12, 2023 14:50
Angular HttpClient (5)
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
/** This class implements some features that should be tested. */
@Injectable()
export class HttpClientFeatureService {
constructor(
private http: HttpClient
@DanDiplo
DanDiplo / JS-LINQ.js
Last active May 20, 2024 10:30
JavaScript equivalents of some common C# LINQ methods. To help me remember!
// JS array equivalents to C# LINQ methods - by Dan B.
// First: This version using older JavaScript notation for universal browser support (scroll down for ES6 version):
// Here's a simple array of "person" objects
var people = [
{ name: "John", age: 20 },
{ name: "Mary", age: 35 },
{ name: "Arthur", age: 78 },
{ name: "Mike", age: 27 },
@flaub
flaub / SqliteContext.cs
Created March 16, 2015 08:21
SQLite EF 6 Database Initializer
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Data.SQLite;
using System.Linq;
namespace SQliteEF6
{
class SqliteContext : DbContext
@biomancer
biomancer / playlist_builder.rb
Created September 18, 2014 14:48
Generating i-frame and byterange m3u8 playlist from .ts video file for usage in HLS
module PlaylistBuilder
SEG_DURATION, PKT_SIZE, PKT_POS, PKT_TIME = 0,1,2,3
def self.extract_iframes_data(video_filepath)
raise "#{video_filepath} does not exists!" unless File.exists?(video_filepath)
iframes_data = []
cmd = "ffprobe -show_frames -select_streams v -of compact -show_entries packet=pts_time,codec_type,pos:frame=pict_type,pkt_pts_time,pkt_size,pkt_pos -i #{video_filepath.shellescape}"
frames_and_packets = nil
r = Benchmark.measure('') do
frames_and_packets = `#{cmd}`.split("\n")
@svagionitis
svagionitis / Create_Iframe_Index_M3U8.bash
Last active January 13, 2024 13:42
Segment an mp4 file to HLS streaming files
#!/bin/bash
# Create an Iframe index from HLS segmented streams
# $1: Filename to be created
# $2: Location of segmented ts files
# Check how many arguments
if [ $# != 2 ]; then
echo "Usage: $0 [Input filename] [Location of segmented streams]"
exit 1;
fi
@hanssens
hanssens / Sitemap.xml
Created October 18, 2012 09:49
[C#] XML SiteMapReader
<?xml version="1.0" encoding="utf-8" ?>
<XmlSiteMap>
<Menu id="home" controller="Home" action="index" title="Mijn Homepage" url="http://mijnhomepage.nl" />
<Menu id="producten" controller="Products" action="overview" title="Mijn Producten" url="http://mijnhomepage/producten/" />
</XmlSiteMap>
@keeguon
keeguon / countries.json
Created April 5, 2012 11:11
A list of countries in JSON
[
{name: 'Afghanistan', code: 'AF'},
{name: 'Åland Islands', code: 'AX'},
{name: 'Albania', code: 'AL'},
{name: 'Algeria', code: 'DZ'},
{name: 'American Samoa', code: 'AS'},
{name: 'AndorrA', code: 'AD'},
{name: 'Angola', code: 'AO'},
{name: 'Anguilla', code: 'AI'},
{name: 'Antarctica', code: 'AQ'},