Skip to content

Instantly share code, notes, and snippets.

@ProximaMonkey
ProximaMonkey / README.markdown
Created April 13, 2012 11:06 — forked from gudbergur/README.markdown
Bootstrap's Typeahead plugin extended (allowing for AJAX functionality) among other things

This is a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

For example, process typeahead list asynchronously and return objects

  # This example does an AJAX lookup and is in CoffeeScript
  $('.typeahead').typeahead(
    # source can be a function
    source: (typeahead, query) ->
 # this function receives the typeahead object and the query string
@ProximaMonkey
ProximaMonkey / foo
Created April 14, 2012 01:51
I hate Internet Explorer
function(container, pins) {
pins.imagesLoaded(function(images){
container.masonry('appended', pins, false);
// IE fix preventing not loading images
jQuery.each(images, function(i, e, c) {
var tmp_src = jQuery(e).attr("src");
if (!e.complete) {
jQuery(e).attr("src", "");
jQuery(e).attr("src", tmp_src);
@ProximaMonkey
ProximaMonkey / webdev.md
Created April 14, 2012 02:03 — forked from dideler/bootstrapping.md
Bootstrapping
@ProximaMonkey
ProximaMonkey / mysql.py
Created April 16, 2012 00:13 — forked from adamv/mysql.py
Simple wrapper around MySQLdb
import collections
import MySQLdb as dbapi
__all__ = ['MySql']
class MySql(object):
def __init__(self, **kwargs):
self.connection = dbapi.connect(**kwargs)
self.host_name = kwargs.get('host')
@ProximaMonkey
ProximaMonkey / nginx.conf
Created April 16, 2012 01:44 — forked from dmdeller/nginx.conf
DuckDuckGo nginx config for handling Safari search bar requests
server {
server_name search.yahoo.com;
# only handle requests from Safari search bar
if ($args ~ fr=aaplw.*p=) {
rewrite ^/search https://duckduckgo.com/?q=$arg_p? break;
}
# attempt to redirect other requests back to Yahoo, using alternative server name
rewrite ^ http://search.ystg1.b.yahoo.com$request_uri? break;
@ProximaMonkey
ProximaMonkey / latency.txt
Created May 31, 2012 12:28 — forked from jboner/latency.txt
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns
Mutex lock/unlock 25 ns
Main memory reference 100 ns
Compress 1K bytes with Zippy 3,000 ns
Send 2K bytes over 1 Gbps network 20,000 ns
Read 1 MB sequentially from memory 250,000 ns
Round trip within same datacenter 500,000 ns
Disk seek 10,000,000 ns
@ProximaMonkey
ProximaMonkey / Async.cs
Created June 7, 2012 09:32 — forked from SamSaffron/Async.cs
Async class for threading
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Threading;
using System.Diagnostics;
using System.Text;
namespace StackOverflow.Helpers
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace System.Linq
{
public class KeyEqualityComparer<T> : IEqualityComparer<T>
{
private readonly Func<T, T, bool> comparer;
@ProximaMonkey
ProximaMonkey / valuetype.cs
Created April 4, 2017 08:16 — forked from yizhang82/valuetype.cs
Generic constraint on boxing
using System;
interface IAdd
{
void Add(int val);
}
struct Foo : IAdd
{
public int value;
@ProximaMonkey
ProximaMonkey / ChatGPT-Translate-Long-Text.js
Created October 1, 2023 12:13 — forked from JimLiu/ChatGPT-Translate-Long-Text.js
使用ChatGPT自动分页翻译长文
// WARNING:此脚本仅做学习和演示用途,在不了解其用途前不建议使用
// 本脚本的用途是将输入内容分页,每次提取一页内容,编辑第二条消息,发送,然后收集结果
// 使用前,需要有两条消息,参考模板 https://chat.openai.com/share/17195108-30c2-4c62-8d59-980ca645f111
// 演示视频: https://www.bilibili.com/video/BV1tp4y1c7ME/?vd_source=e71f65cbc40a72fce570b20ffcb28b22
//
(function (fullText) {
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const groupSentences = (fullText, maxCharecters = 2800) => {
const sentences = fullText.split("\n").filter((line) => line.trim().length > 0);