Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Diogo Gomes Alphabetus

🎯
Focusing
View GitHub Profile
@Alphabetus
Alphabetus / main.rb
Created Jan 5, 2022 — forked from amirrajan/main.rb
DragonRuby Game Toolkit - Sand Simulation via Cellular Automata
View main.rb
class Elements
def initialize size
@size = size
@max_x_ordinal = 1280.idiv size
@element_lookup = {}
@elements = []
end
def add_element x_ordinal, y_ordinal
return nil if @element_lookup.dig x_ordinal, y_ordinal
@Alphabetus
Alphabetus / javascript:number_to_currency
Created May 21, 2021 — forked from zaagan/javascript:number_to_currency
javascript: number to currency. Rails like
View javascript:number_to_currency
function number_to_currency(number, options) {
try {
var options = options || {};
var precision = options["precision"] || 2;
var unit = options["unit"] || "$";
var separator = precision > 0 ? options["separator"] || "." : "";
var delimiter = options["delimiter"] || ",";
var parts = parseFloat(number).toFixed(precision).split('.');
return unit + number_with_delimiter(parts[0], delimiter) + separator + parts[1].toString();
@Alphabetus
Alphabetus / minecraft-forge-java8.json
Created Jan 3, 2021
Puffer panel template for minecraft forge
View minecraft-forge-java8.json
{
"pufferd": {
"type": "java",
"display": "Forge - Java8",
"install": {
"commands": [
{
"type": "download",
"files": "http://files.minecraftforge.net/maven/net/minecraftforge/forge/${version}/forge-${version}-installer.jar"
},
View gist:d54409060091607dd6350c189108d857
!sub-team <teamId>
!unsub-team <teamId>
!sub-league <leagueId>
!unsub-league <leagueId>
!match-data <matchId>
!team-games <teamId>
!league-matches <leagueId>
!next-match
!live-match
!bet <matchId> <bet>
@Alphabetus
Alphabetus / DemoController.php
Last active Dec 12, 2020
Remote Requests Symfony - Render JS template asynchronously with Twig parameters
View DemoController.php
<?php
/**
* @Route("/test.js", name="app.test")
*/
public function test()
{
$optionalParams = array('foo'=>'bar');
$renderedView = $this->renderView("test.js.twig");
$resp = new Response($renderedView, $optionalParams);
$resp->headers->set('Content-Type','text/javascript');
@Alphabetus
Alphabetus / index.php
Last active Mar 16, 2020
get handlers for Magento Debugging on index.php
View index.php
/**
* NOTE:
* Retrieves the handlers used by Magento on frontend.
* Example:
* array(8) { [0]=> string(7) "default" [1]=> string(8) "cms_page" [2]=> string(13) "STORE_default" [3]=> string(29) "THEME_frontend_custom_default" [4]=> string(15) "cms_index_index" [5]=> string(22) "page_two_columns_right" [6]=> string(19) "customer_logged_out" [7]=> string(8) "cms_menu" }
**/
var_dump(Mage::app()->getLayout()->getUpdate()->getHandles());
@Alphabetus
Alphabetus / __readme.md
Created Feb 20, 2020 — forked from maxivak/__readme.md
Tree with ancestry. Rails
View __readme.md

Contents:

  • show full path for the item
  • show tree in ol li
  • show tree in dropdown select

Show full path for item

  • one item
View translations.js
var translations = {
// hindi
hindi: {
// story 01
1: [
"मध्यस्थ: एक शाम तेनाली रामा अपनी जॉय फिर तेनाली रामा की पत्नी को देखकर बहुत खुश होकर महल से घर लौटा। वसुधा ने उससे पूछा।",
"पत्नी: क्या तुम आज बहुत खुश नहीं लग रहे हो?",
"रामा: हाँ। क्यों नहीं? मुझे आज खुश क्यों नहीं दिखना चाहिए?",
"पत्नी: क्यों क्या हुआ है?",
"रामा: ओह! वसुधा आज राजा कृष्णदेवराय ने अपने बगीचे में उगाए गए बैंगन से सब्जी बना कर उसे गर्म करने के बाद कढ़ी पर भोज के लिए सभी लोगों को आमंत्रित किया था। मैं वह भूल नहीं पा रहा हूँ।",
View table_for_story.html
<table data-storyid="100" border="0">
<tbody>
<tr>
<td>Speaker 1:</td>
<td>sentence A.</td>
</tr>
<tr>
<td>Speaker 2:</td>
@Alphabetus
Alphabetus / async_rake.rb
Created Sep 19, 2019 — forked from tompave/async_rake.rb
how to run rake tasks asynchronously from controllers by spawning child processes
View async_rake.rb
class ApplicationController < ActionController::Base
def perform_async(task, options = {})
options[:rails_env] ||= Rails.env
env_vars = options.map { |key, value| "#{key.to_s.upcase}='#{value.to_s}'" }
env_vars_string = env_vars.join(' ')
Process.fork {exec("#{env_vars_string} bin/rake #{task}")}
end
end