Skip to content

Instantly share code, notes, and snippets.

@myshov
myshov / function_invocation.js
Last active January 21, 2024 15:14
11 Ways to Invoke a Function
console.log(1);
(_ => console.log(2))();
eval('console.log(3);');
console.log.call(null, 4);
console.log.apply(null, [5]);
new Function('console.log(6)')();
Reflect.apply(console.log, null, [7])
Reflect.construct(function(){console.log(8)}, []);
Function.prototype.apply.call(console.log, null, [9]);
Function.prototype.call.call(console.log, null, 10);
@XPlantefeve
XPlantefeve / LICENSE.txt
Last active April 12, 2022 10:02
Powershell Gist management CMDlets
MIT License
Copyright (c) 2016 Xavier Plantefeve
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@durcheinandr
durcheinandr / sidenotes.vim
Created April 17, 2016 15:04
Add Sidenotes to every file. Sidenotes are sidecar files in a custom directory
" let g:snotepath = '/path/to/your/sidenotes/'
" let g:snoteext = 'md'
" defaults for sidenotes-directory and extension
if !exists('g:snotepath')
let g:snotepath = $HOME . '/sidenotes/'
endif
if !exists('g:snoteext')
let g:snoteext ='markdown'
anonymous
anonymous / index.html
Created March 29, 2016 21:37
JS Bin // source https://jsbin.com/yupomu
<!DOCTYPE html>
<html>
<head>
<title>JS Bin</title>
<script src="https://code.createjs.com/easeljs-0.8.2.min.js"></script>
<script>
var image;
var fpstext;
var stage;
function init() {
@n074v41l4bl34u
n074v41l4bl34u / set-dns.cmd
Created March 20, 2016 19:41
set static dns for network connection using windows console cmd script
@echo off
IF [%1] EQU [] goto noInterface
:: OPENDNS - OpenDNS, LLC,US
set DNS1=208.67.222.123
:: Google DNS
set DNS2=8.8.4.4
for /f "skip=2 tokens=1,2,3*" %%i in ('netsh int show interface') do (
@Hexalon
Hexalon / Imaging-Win10.ps1
Last active August 17, 2017 18:05
Provides interactive/automated imaging operations using DISM and WinPE
#requires -version 4.0
#requires -modules Storage,DISM
#Requires -RunAsAdministrator
<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.2.117
Created on: 3/16/2016 10:05
Created by: Colin Squier <hexalon@gmail.com>
Filename: Imaging-Win10.ps1
@dannguyen
dannguyen / shakespeare-ngrams-cli-ack.md
Last active May 30, 2023 16:04
How to tokenize and create n-grams in Shakespeare from the command-line

Creating Shakespearean n-grams with just the command-line and regexes

This is a quick example showing how to use regexes to find tri-grams in Shakespeare...well, 570,872 of them, anyway, if we do some basic filtering of non-dialogue.

Though tokenization and n-grams should typically be done using a proper natural language processing framework, it's possible to do in a jiffy from the command-line, using standard Unix tools and ack, the better-than-grep utility.

What are n-grams?

# In reply to comment https://www.reddit.com/r/PowerShell/comments/47wc3x/ive_been_asked_to_come_up_with_35_questions_to/d0g8bgd
$Hash = @{
"a" = 5
"b" = 4
"c" = 3
"d" = 2
"e" = 1
}
#Function to fetch the data from Wolfram|Alpha API based on user query
Function Invoke-WolframAlphaAPI($Query)
{
Return (Invoke-RestMethod -Uri "http://api.wolframalpha.com/v2/query?appid=APIKEY&input=$($Query.Replace(' ','%20'))").queryresult
}
#Eventhandler and Flow control once the Search button is pressed
$EventHandler =[System.EventHandler]{
$Panel2.Visible = $False
  1. CGI.pm is shit
  2. CGI is shit
  3. <"ARGV"> shouldn't work under use strict because thats a string dereferencing a symbolic ref.
  4. Hash Keys can't retain tainting and so can be used to propagate un-vetted data into safe spaces:
  my $hash = unsafe_thing_that_returns_a_hash();
  $dbh->query(join keys %{$hash}); # data will be untained regardless of what it is.
  1. CGI.pm should probably do something smarter than simply returning the first param when >1 params