How to add or use functions on Atom snippets? - code-snippets

I want to know if it is possible to create or call functions to use on snippets in the Atom editor. If possible, how do I do it ? Maybe using lodash or something similar ?
I want to use something like uppercase(), downcase(), filePath().
My problem is that I want to generate something like this line below:
import Hello from 'components/atoms/hello/Hello';
My snippet would be something like this:
import $1 from 'components/atoms/downcase($1)/$1';
Or:
import camelCase($1) from 'components/atoms/$1/camelCase($1)';

This behavior is still an opened issue. So it's seems there is no solution right now for this, sorry.
Here is the issue.

Related

LUA - Calling function from other module without exporting table

I try to setup a special behavior with Jitsi, but have not that much LUA knowlege.
A Jitsi/Prosody module "mod_muc_lobby_rooms.lua" is implementing some function like handle_create_lobby(event);. handle_create_lobby is calling other sub-function from inside.
https://github.com/jitsi/jitsi-meet/blob/master/resources/prosody-plugins/mod_muc_lobby_rooms.lua
But the module itself is not a library module, so no table is exported and another code can use "require". So my understanding from LUA yet.
For a own module, I just want use this functions from the other side, without reimplement or copy/paste it.
Is there any solution, how I can "source" the function into my module?
If possible, I want let "mod_muc_lobby_room.lua" unchanged, if some updates from Jitsi are coming.
Thanks in advance.
A lua beginner, Uwe
You can fire an event because it listen for it.
prosody.events.fire_event("create-lobby-room", event)
Or you can use the module function like this:
local muc_lobby_rooms = module:depends("muc_lobby_rooms");
muc_lobby_rooms.handle_create_lobby(event);
You can do it like that:
file=io.open("mod_muc_lobby_room.lua")
io.input(file)
load(io.read("*a"))()
io.close(file)
And the code located in mod_muc_lobby_room.lua will be executed.

How to apply FBMemoryProfiler to cocos2d-x iOs game?

I want to apply the FBMemoryProfiler for cocos2dx iOs game.
First, I create a simple demo, "cocos new CocosGame -p com.test -l cpp". There are a lot of projects of the demo, like proj.ios_mac, proj.android, proj.linux...
I chose the ios_mac one and it works fine.
Then, I create a podfile to import the FBMemoryProfiler in proj.ios_mac and I use podfile to install FBMemoryProfiler.
However, when I open the CococsGame.xcworkkspace, there are a lot of errors, like
cannot find libFBAllocationTracker.a
I really want to know how to apply FBMemoryProfiler for cocos2d, what am I doing wrong?
You need to include FBAllocationTracker in your demo first.
You can do that by including the following
import FBAllocationTracker
in the headers and in the main method
FBAllocationTrackerManager.sharedManager()?.startTrackingAllocations()
into your main.swift
PS: You might wanna enable Generations by adding the following line with the above :
FBAllocationTrackerManager.sharedManager()?.enableGenerations()
If you have already done the above and still getting the same error, it looks like your project is not linking the FBAllocationTracker properly and you might wanna look at the https://github.com/facebook/FBMemoryProfiler "Usage" section again to see if you are missing something.

Using signature file in script

I like using .fsi signature files to control visibility. However, if I have both Foo.fsi and Foo.fs files in my solution, and #load "Foo.fs" in a script, it doesn't seem like the corresponding signature file gets used. If I do:
#load "Foo.fsi"
#load "Foo.fs"
... then the desired visibility control happens. Is this the recommended way to achieve this, or is there a better way to do it? In a perfect world, one would like to see the signature file automatically loaded, too.
Not a final answer, but a better way.
From reading Expert F# 4.0 one can do
#load "Foo.fsi" "Foo.fs" "Foo.fsx"
All three loads are on one line.
TL;DR
The link to the book is via WolrdCat just put in a zip code and it will show you locations near there where the book can be found.

ZF2 BBCode Parser

Hiho,
I use the ckeditor on my website for special textareas like forum
or signatures.
But I have a problem with the output. I use ZF2 and would like to
use ZendMarkup to render the output bbcode back in html.
But at every time I call
$bbcode->render(...)
I got the error
There is no Zend_Markup_Root markup.
The ZendMarkup is an extension inspired by the Zend_Markup from ZF1.
But I can't find any thing on API or other guides.
Does someone has any idea what as the problem is?
The ZendMarkup library is very old (last update is 10 months ago!) so I wouldn't use such library. If you would like, I think I traced the error down.
On this line there is a reference to Zend_Markup_Root while that should be ZendMarkup\Renderer\Markup\Html\Root. Try to change that line and see what happens.
Another way is to replace the ZendMarkup library with another library which does work and is updated regularly. An example is Decoda. If you load mjohnson/decoda in your composer.json, you can use Decoda in your Zend Framework 2 application:
<?php
use Decoda\Decoda;
$parser = new Decoda($bbcode);
$html = $parser->parse();
With tools like composer, there is no need to use solely Zend* components when there are better alternatives.

Using not operation in hamcrest

I was recently trying to assert the inequality in one of the test. However I wasnt able to find the appropriate matcher in hamcrest.
What I ideally want to do is something like.
assertThat(2 , isNot(3));
Is there any way to do it?
You're almost there:
assertThat(2 , is(not(3)));
Be sure you import it:
import static org.hamcrest.CoreMatchers.not;

Resources