Skip to content

Instantly share code, notes, and snippets.

View Nexuist's full-sized avatar

Andi Andreas Nexuist

View GitHub Profile
@Nexuist
Nexuist / thinking.js
Last active September 17, 2017 00:09
Paste this into Discord's DevTools for a TouchBar thinking emoji (🤔) button.
const {TouchBar} = require("electron").remote;
const {TouchBarButton} = TouchBar;
let thinkingButton = new TouchBarButton({
label: "🤔",
backgroundColor: "#7851A9",
click: () => {
let chatbox = document.getElementsByTagName("textarea")[0];
chatbox.value += " :thinking:";
const text = "Congratulations! You won the Unreplied giveaway! Here's your promo code: PROMO. Thanks for participating! Make sure you tell all of your Mac friends about it too, they might like it as well!"
const codes = fs.readFileSync("promo_codes.txt", "utf8").split("\n"); // A text file with a promo code on each line
function generateLine(user) {
let encodedText = encodeURIComponent(text).replace(/'/g, "%27").replace("PROMO", codes.pop());
let link = `https://twitter.com/messages/compose?recipient_id=${user.id}&text=${encodedText}`;
return `${user.name} (@${user.screen_name}) - ${link}`;
}
// https://stackoverflow.com/a/11935263 - Thanks Tim!
function getRandomSubarray(arr, size) {
var shuffled = arr.slice(0), i = arr.length, temp, index;
while (i--) {
index = Math.floor((i + 1) * Math.random());
temp = shuffled[index];
shuffled[index] = shuffled[i];
shuffled[i] = temp;
}
return shuffled.slice(0, size);
const fs = require("fs");
const maybeEligible = JSON.parse(fs.readFileSync('maybe-eligible.json', 'utf8'));
const eligible = maybeEligible.filter((entry) => "followed_by" in entry.connections);
const fs = require("fs");
const retweets = JSON.parse(fs.readFileSync('retweets.json', 'utf8'));
console.log(retweets.map((retweet) => retweet.user.id).join(","));
@Nexuist
Nexuist / DNA-Minisite.jade
Last active August 12, 2016 13:32
A quick story on salvaging a failing school project and going from lazy and late to efficient and just-in-time.
doctype html
html
head
meta(charset='utf-8')
meta(name='viewport', content='width=device-width, initial-scale=1')
meta(http-equiv='Content-Type', content='text/html; charset=UTF-8')
meta(http-equiv='X-UA-Compatible', content='IE=edge')
title DNA
link(href='http://bootswatch.com/sandstone/bootstrap.min.css', rel='stylesheet')
link(rel='icon', type='image/ico', href='http://www.deplex.net/favicon.ico', sizes='32x32')
@Nexuist
Nexuist / vol.mm
Last active August 12, 2016 13:34
A command line tool for iOS that can get and set different volume categories.
// Last modified Jan 22, 2014
#include <stdlib.h>
@interface AVSystemController : NSObject
+ (id)sharedAVSystemController;
- (BOOL)setActiveCategoryVolumeTo:(float)arg1;
- (BOOL)getActiveCategoryVolume:(float*)arg1 andName:(id*)arg2;
@end
@Nexuist
Nexuist / Student.java
Last active July 25, 2016 23:56
Demonstrating inheritance, scope, and ArrayList usage for CS115
//********************************************************************
// Student.java
//
// Represents a college student.
//********************************************************************
import java.util.ArrayList;
public class Student {
private String firstName, lastName;
@Nexuist
Nexuist / vehicle.php
Last active January 15, 2016 14:36
A class in PHP meant to emulate a vehicle.
<?php
class Vehicle {
public $name = "Unnamed";
public $doors = 4;
public $gates = 1;
public $mpg = 25;
public $odometer = 0;
public $speed = 0;