Skip to content

Instantly share code, notes, and snippets.

@MrAlexWeber
MrAlexWeber / 76-Minimum_Window_Substring.ts
Last active August 23, 2021 18:30 — forked from sourabh2k15/76-Minimum_Window_Substring.cpp
Leetcode 76. Minimum Window Substring (TypeScript version)
// I rewrote this solution in TypeScript for practice.
function minWindow(s: string, t: string): string {
let table: Map<string, number> = new Map()
// Initialize frequency table
for (const char of t) {
const prev = table.get(char)
if (prev) {
table.set(char, prev + 1)
210-348-5000
210-348-5001
210-348-5002
210-348-5003
210-348-5004
210-348-5005
210-348-5006
210-348-5007
210-348-5008
210-348-5009
210 - 348
212 - 348
213 - 348
214 - 348
215 - 348
216 - 348
217 - 348
218 - 348
310 - 348
312 - 348
@MrAlexWeber
MrAlexWeber / install-moon-macos.sh
Created July 13, 2020 17:12
How to run wttr.in/Moon (pyphoon) locally
#!/bin/sh
# This is what I did, YMMV
# See also: https://github.com/chubin/pyphoon/issues/27
cd ~
git clone https://github.com/chubin/pyphoon
cd pyphoon
pip install -r requirements.txt
chmod +x setup.py
./setup.py develop
function wrap_html_attr($atts, $content = null){
/* input e.g. 'value="[some_shortcode]"' */
return do_shortcode( $content );
}
add_shortcode( 'wha', 'wrap_html_attr' );
@MrAlexWeber
MrAlexWeber / dev-or-prod-widget.php
Created November 13, 2013 22:37
Simple WordPress widget to check if you're in a development environment.
<?php
/* dev_or_prod_widget by mr.alexweber@gmail.com
** checks our IP against the DNS record for our hostname
** if they don't match, this is probably a development server
*/
function dev_or_prod_widget() {
$my_ip = trim( file_get_contents('http://icanhazip.com') );
$my_domain = $_SERVER['SERVER_NAME'];
$official_ip = gethostbyname($my_domain);
@MrAlexWeber
MrAlexWeber / charisma-score-calculation.php
Created November 13, 2013 22:35
Code Samples part 2…
<?php
/* This was used on a marketing quiz based on a formula provided by a marketer.
It was my job to make his rough logic into something that worked!
*/
/* description:
** pull variables from $_POST: conf, char, aggr, rapp, kiss, date
** quiz_points = scale(20=0, 100=50)(conf + char + aggr + rapp)
**
** kiss_points = kiss * 2.5 (maximum of 25)
<?php
/* This bit is in use on my site still, originally coded in 2012.
You can see an example on this page: http://alexweber.is/nerdy/
*/
/** custom page+category logic **/
function list_posts_if_also_category() {
if(is_page() && !is_home() && !is_front_page()){
$this_post_title = the_title('','',FALSE);
@MrAlexWeber
MrAlexWeber / lame-make-mp3-mono.sh
Created September 18, 2012 00:05
make an MP3 mono @ 48kbps with LAME
lame --mp3input -a -b 48 --resample 44.1 infile.mp3 [outfile.mp3]
@MrAlexWeber
MrAlexWeber / remove posts from category.sql
Created May 4, 2012 01:46
sql to remove posts from a category given a post author and category id
delete b
from wp_posts a
left join wp_term_relationships b ON ( a.ID = b.object_id )
LEFT JOIN wp_term_taxonomy d ON ( d.term_taxonomy_id = b.term_taxonomy_id )
LEFT JOIN wp_terms e ON ( e.term_id = d.term_id )
WHERE e.term_id = YOUR_TERM_ID and a.post_author = YOUR_AUTHOR_ID;