This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Singleton(object): | |
| def __new__(cls): | |
| if not cls.singleton: | |
| cls.singleton = object.__new__(cls) | |
| return cls.singleton | |
| class Foo(Singleton): | |
| singleton = None | |
| pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Hooks(object): | |
| @staticmethod | |
| def before(name): | |
| def decorator(func): | |
| def wrap(self, *args): | |
| self.__getattribute__(name)() | |
| func(self, *args) | |
| return wrap | |
| return decorator |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| def hash(string) | |
| hash = {} | |
| string.each_char do |c| | |
| hash[c] = hash[c].to_i + 1 | |
| end | |
| return hash | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
NewerOlder