Skip to content

Instantly share code, notes, and snippets.

View theodesp's full-sized avatar
🦄
Jumping over Rainbows...

Theofanis Despoudis theodesp

🦄
Jumping over Rainbows...
View GitHub Profile
"dependencies": {
"gatsby": "^2.20.12",
"gatsby-plugin-manifest": "^2.1.1",
"gatsby-plugin-offline": "^2.1.1",
"gatsby-plugin-react-helmet": "^3.0.12",
"gatsby-source-filesystem": "^2.0.38",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-helmet": "^5.2.1",
},
// This is a proper alternative to
// https://github.com/BuckleScript/bucklescript/blob/b9508105b1a35537bdea9a1fabd10f6c65f776b4/jscomp/bsb/templates/react-hooks/src/FetchedDogPictures/FetchedDogPictures.re#L14
// The one in that file uses Promise, but that's *wrong*.
// We only used promise as a demo of its API. We'll remove it soon.
// As you can see below, the pure XMLHttpRequest code is just as clean,
// less mysterious for all, more performant, extensible, and actually correct.
// Ignore these externals for now. They're just for illustration
// purposes. I just copy pasted the Js code from
@theodesp
theodesp / main.java
Created March 12, 2020 13:17
Get Current Locale
package com.thdespou;
import java.util.Locale;
public class Main {
public static void main(String[] args) {
System.out.println(Locale.getDefault());
}
}
@theodesp
theodesp / main.java
Created March 11, 2020 20:51
ZonedDateTime example
package com.thdespou;
import java.time.*;
public class Main {
public static void main(String[] args) {
Instant now = Instant.now();
ZonedDateTime zdt = ZonedDateTime.ofInstant(now,
ZoneId.systemDefault());
@theodesp
theodesp / main.java
Created March 11, 2020 20:42
UTC in Java
package com.thdespou;
import java.time.Instant;
public class Main {
public static void main(String[] args) {
Instant now = Instant.now();
System.out.println("Date is " + now);
}
@theodesp
theodesp / main.java
Last active March 11, 2020 19:20
Date with Timezone
package com.thdespou;
import java.util.Date;
import java.util.TimeZone;
public class Main {
public static void main(String[] args) {
// Date
Date now = new Date();
@theodesp
theodesp / main.java
Created March 11, 2020 18:13
Get current time
package com.thdespou;
import java.util.Date;
public class Main {
public static void main(String[] args) {
// Date
Date now = new Date();
System.out.println("Current Date in milliseconds is :" + now.getTime());
{% if app.environment == 'translation' %}
window.PHRASEAPP_CONFIG = {
projectId: "YOUR-PROJECT-ID"
};
(function() {
var phraseapp = document.createElement('script'); phraseapp.type = 'text/javascript'; phraseapp.async = true;
phraseapp.src = ['https://', 'phraseapp.com/assets/in-context-editor/2.0/app.js?', new Date().getTime()].join('');
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(phraseapp, s);
})();
public function process(ContainerBuilder $container)
{
if ($this->environment == 'translation')
{
$definition = $container->getDefinition('translator.default')->setPublic(true);
$definition->setClass('App\AppBundle\PhraseTranslator');
}
}
<?php
namespace App\AppBundle;
use Symfony\Bundle\FrameworkBundle\Translation\Translator as BaseTranslator;
class PhraseTranslator extends BaseTranslator
{
public function trans($id, array $parameters = array(), $domain = "messages", $locale = null)