Skip to content

Instantly share code, notes, and snippets.

View Tomamais's full-sized avatar

Tomás Tomamais

View GitHub Profile
@Tiberriver256
Tiberriver256 / PowerShellNTFSStaticFileServer.ps1
Last active July 29, 2024 12:16
This script starts a small web server listening on localhost:8080 that will impersonate the authenticated user and serve static content. This means if they do not have NTFS permissions to the file they will get an access denied or a 404 file not found if they do not have NTFS access to list contents of the directory.
function Get-DirectoryContent {
<#
.SYNOPSIS
Function to get directory content
.EXAMPLE
Get-DirectoryContent -Path "C:\" -HeaderName "poshserver.net" -RequestURL "http://poshserver.net" -SubfolderName "/"
@AmirHossein
AmirHossein / coordinatestoname.js
Last active December 25, 2023 11:15
Get City and Country name by coordinates via Google Maps api
// Demo: http://jsfiddle.net/xuyp8qb5/
// Note: You need Google Map API Key to run demo; bit.ly/2pBgToW
var latlng;
latlng = new google.maps.LatLng(40.730885, -73.997383); // New York, US
//latlng = new google.maps.LatLng(37.990849233935194, 23.738339349999933); // Athens, GR
//latlng = new google.maps.LatLng(48.8567, 2.3508); // Paris, FR
//latlng = new google.maps.LatLng(47.98247572667902, -102.49018710000001); // New Town, US
//latlng = new google.maps.LatLng(35.44448406385493, 50.99001635390618); // Parand, Tehran, IR
//latlng = new google.maps.LatLng(34.66431108560504, 50.89113940078118); // Saveh, Markazi, IR
@stephanecoinon
stephanecoinon / VBA collectionToArray
Created December 11, 2013 20:47
VBA converts a collection to array
' Source: http://www.iwebthereforeiam.com/iwebthereforeiam/2004/06/excel-vba-code-to-convert-coll.html
Function collectionToArray(c As Collection) As Variant()
Dim a() As Variant: ReDim a(0 To c.Count - 1)
Dim i As Integer
For i = 1 To c.Count
a(i - 1) = c.Item(i)
Next
collectionToArray = a
End Function
@mrkodssldrf
mrkodssldrf / DatareaderToList
Created October 17, 2013 12:25
Convert SQL Datareader to List<T> C#
public List<T> Query<T>(string query) where T:new()
{
List<T> res = new List<T>();
MySqlCommand q = new MySqlCommand(query, this.db);
MySqlDataReader r = q.ExecuteReader();
while (r.Read())
{
T t = new T();
for (int inc = 0; inc < r.FieldCount; inc++)
@foofoodog
foofoodog / powershell-winform.ps1
Created July 8, 2012 13:52
powershell-winform
New-Module -ScriptBlock {
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
$form = New-Object System.Windows.Forms.Form
$grid = New-Object System.Windows.Forms.PropertyGrid
$grid.Dock = [System.Windows.Forms.DockStyle]::Fill
$button = New-Object System.Windows.Forms.Button
$button.Text = "OK"
$button.Dock = [System.Windows.Forms.DockStyle]::Bottom
@chrisguitarguy
chrisguitarguy / default-author.php
Created July 2, 2012 20:07
Set a default author for posts on your WordPress site.
<?php
/*
Plugin Name: Default Author
Plugin URI: http://pmg.co
Description: Set a default author for all posts and pages
Version: 1.0
Text Domain: default-author
Author: Christopher Davis
Author URI: http://christopherdavis.me
License: GPL2