Skip to content

Instantly share code, notes, and snippets.

View shelling's full-sized avatar

shelling shelling

View GitHub Profile
import { readFileSync } from 'fs'
import OpenAI from 'openai';
import { ChatCompletionMessageParam } from 'openai/resources/chat';
import inquirer from 'inquirer';
import input from '@inquirer/input';
import {
Product,
var Func = function(e) {
"use strict";
var a, t = $("#ECPayPayment"),
n = e.sdkVersion,
c = e.token,
i = e.language,
d = e.cliPriKey,
r = e.serPubKey,
s = e.keyID,
p = e.uuid,
class Singleton(object):
def __new__(cls):
if not cls.singleton:
cls.singleton = object.__new__(cls)
return cls.singleton
class Foo(Singleton):
singleton = None
pass
class Hooks(object):
@staticmethod
def before(name):
def decorator(func):
def wrap(self, *args):
self.__getattribute__(name)()
func(self, *args)
return wrap
return decorator
# Project Euler 26
def recurring(number)
remainders = Hash.new(0)
value = 1
position = 0
length = 0
while value != 0 && remainders[value] == 0
remainders[value] = position
def anagram?(s1, s2)
hash = Hash.new(0)
s1.each_char do |c|
hash[c] += 1
end
s2.each_char do |c|
hash[c] -= 1
end
hash.values.uniq == [0]
end
#!/usr/bin/env ruby
class String
def *(str)
maxshift = self.length + str.length - 2
results = Array.new(maxshift+1, 0)
self.split(//).map(&:to_i).each_with_index do |i, at1|
#!/usr/bin/env ruby
def integer?(number)
(number % 1) == 0
end
def double_square_number?(number)
sqrt = Math.sqrt(number)
if integer?(sqrt)
[sqrt.to_i, 0]
#!/usr/bin/env ruby
def hash(string)
hash = {}
string.each_char do |c|
hash[c] = hash[c].to_i + 1
end
return hash
end
#!/usr/bin/env ruby
class Node
attr_accessor :data, :left, :right
def initialize(data, left = nil, right = nil)
@data = data
@left = left
@right = right
end