#gettimestamp
Explore tagged Tumblr posts
nddnews · 8 years ago
Text
'Matheus é o novo fazendeiro', Bombom e Flávia estão na roça
'Matheus é o novo fazendeiro', Bombom e Flávia estão na roça
Ana Paula Minerato, a fazendeira da semana, indicou Bombom. Já Flávia recebeu dez votos da casa. Matheus acabou indo para a berlinda por indicação de Flávia Matheus Lisboa venceu a prova realizada na noite desta terça-feira e se tornou o novo fazendeiro do reality show "A Fazenda". A competição
Notícias Do Dia
Leia a postagem completa: http://www.noticiasdodia.info/2017/09/matheus-e-o-novo-fazendeiro-bombom-e-flavia-estao-na-roca/
1 note · View note
mulherama · 8 years ago
Text
New Post has been published on Mulherama
New Post has been published on http://mulherama.info/2017/07/juiz-encerra-processo-por-pichacao-contra-bieber-apos-doacao-de-r-20-mil/
Juiz encerra processo por pichação contra Bieber após doação de R$ 20 mil
Valor pago pelo cantor foi revertido em material médico e equipamentos para o Inca. Multa foi proposta pelo Ministério Público
Cantor pichou muro de antigo hotel em São Conrado, na Zona Sul
Foto: Efe
O processo contra o cantor Justin Bieber por pichação em um muro no Rio em 2013 foi extinto na última terça-feira. A decisão de deixar Justin livre das acusações foi do juiz Rudi Baldi Lowenkron, da 34ª Vara Criminal, após doação de R$ 20 mil co cantor ao Instituto Nacional do Câncer (INCA).
A doação do cantor teria acontecido em maio e o valor revertido pelo hospital em materiais e equipamentos. Uma vez que o delito cometido por Bieber foi de menor potencial ofensivo e que o cantor não tinha nenhuma anotação, o Ministério Público propôs a aplicação de uma multa que seria revertida em doações ao Inca. O juiz foi informado do ato e decidiu pela absolvição de Bieber.
Vale ressaltar que quando veio ao Rio em 2013, o cantor tinha autorização para pichar um muro da Vila Olímpica do Vidigal, mas ignorou a orientação e foi flagrado pichando um muro, em São Conrado, na Zona Sul do Rio.
1 note · View note
sitedemulher · 8 years ago
Text
Faustão erra nome de Pabllo Vittar e vira piada nas redes sociais
Faustão erra nome de Pabllo Vittar e vira piada nas redes sociais
Cantora ganhou prêmio de Música do Ano com ‘K.O’ no Troféu Domingão – Melhores do AnoPabllo Vittar virou um fenômeno pop em 2017 e, para fechar o ano, a cantora ganhou o prêmio de Música do Ano com “K.O.” no Troféu Domingão – Melhores do Ano, desbancando “P
Site De Mulher
Leia a postagem completa: http://www.sitedemulher.net/2017/12/faustao-erra-nome-de-pabllo-vittar-e-vira-piada-nas-redes-sociais/
0 notes
mulherativa · 8 years ago
Text
Fátima Bernardes posta foto romântica: ‘Quem sabe isso quer dizer amor’
Fátima Bernardes posta foto romântica: ‘Quem sabe isso quer dizer amor’
Apresentadora assumiu romance com Túlio Gadelha recentemente Fátima Bernardes postou no Instagram, na manhã desta segunda-feira, uma foto em que aparece andando de bicicleta com o novo namorado, Túlio Gadelha. A apresentadora e o rapaz assumiram o relacionamento recentemente e parecem estar
Mulher Ativa
Leia a postagem completa: https://mulherativa.com/2017/11/fatima-bernardes-posta-foto-romantica-quem-sabe-isso-quer-dizer-amor/
0 notes
sitecoisademulher · 8 years ago
Text
Fátima Bernardes posta foto romântica: ‘Quem sabe isso quer dizer amor’
Fátima Bernardes posta foto romântica: ‘Quem sabe isso quer dizer amor’
Apresentadora assumiu romance com Túlio Gadelha recentementeFátima Bernardes postou no Instagram, na manhã desta segunda-feira, uma foto em que aparece andando de bicicleta com o novo namorado, Túlio Gadelha. A apresentadora e o rapaz assumiram o relacionamento recentemente e parecem estar bas
Coisa De Mulher
Leia a postagem completa: http://www.coisademulher.info/2017/11/fatima-bernardes-posta-foto-romantica-quem-sabe-isso-quer-dizer-amor/
0 notes
mundolatinomedia · 7 years ago
Text
Gigantes da tecnologia miram em Nova York
Gigantes da tecnologia miram em Nova York
'); } var _aep = _aep || []; (function(d, s, c) { var getTimestamp = function() { var date = new Date(); return ('00' + date.getFullYear()).slice(-2) + ('00' + date.getMonth()).slice(-2) + ('00' + date.getDate()).slice(-2); }; _aep.push(['tag', '5a3293e773303e0004a20c9d', { /* add optional custom config here */ }]); _aep.push(['tag', '5a1700b1e62fcf00048a6cf3', { /* add optional custom config…
View On WordPress
0 notes
espinr · 7 years ago
Text
Implementation of Low-Cost Activ-IoTy Checkpoint in Python  (Bluetooth Keypad)
Update of the ActivIoTy project for the Eclipse Open IoT Challenge.
This is a cheap option to implement an Activ-IoTy compatible checkpoint.
Athletics events are usually controlled by officials with different roles such as: judges, timekeepers and starters. Other competitions must rely on officials with other roles, even volunteers or marshals. This solution enables officials and volunteers to register athletes at checkpoints using a simple physical keypad to type athlete's bib numbers.
Since all athletes must wear a visible bib identifier, this implementation is compatible with the existing rules of official competitions. Keypad may be substituted by a complete keyboard. Of course, the keypad could be a capacitive screen (i.e., tablet, smartphone, etc.) but it is probed that data input operators are more efficient with physical typing devices. Also they may be robust, even waterproof.
This solution only needs a bluetooth input device connected to a Raspberry Pi, or similar.
Tumblr media
The official located nearby the checkpoint type the bib number and press enter to register athletes' checkinw. The system will send the information (bib number + timestamp) of this checkin automatically.
The implementation is based on the module I developed to implement the Checkpoint based on a RFID Reader.
Both approaches implement a generic Reader that performs two main tasks: initialization (setup of the checkpoint) and doInventory.
class Reader(object): def __init__(self): pass def initialize(self): pass def doInventory(self): pass
They also use a common class Checkpoint that implements all the basic functionality of a checkpoint:
Get reliable timestamps from a common NTP server;
Establish a connection with the MQTT server (once it is connected and set-up sends a {checkpointId}/ready message);
Through a Reader, read either bib numbers or RFID EPCs that are related to each competitor (once they are read, they are sent to the MQTT queue under the topic {checkpointId}/checkin);
This is executed in an infinite loop. The controller will be in charge of deal with the messages and do the business logic.
The Checkpoint is implemented using ntplib and paho.mqtt. This is a summary of the code:
# ... imports ... import ntplib import paho.mqtt.publish as publish class Checkpoint(object): TOPIC_READY = 'ready' TOPIC_CHECKIN = 'checkin' def __init__(self, id, reader, mqttBrokerHost, mqttBrokerPort=1883): ''' :param id: String with the identifier of the Checkpoint :param reader: Ind903Reader object (or other Reader) that will do the inventory :param mqttBrokerHost: String with the hostname of the MQTT broker :param mqttBrokerPort: (int) with the port of the MQTT broker (1883 by default) ''' self.id = id self.reader = reader self.mqttBrokerHost = mqttBrokerHost self.mqttBrokerPort = mqttBrokerPort self.timestampOffset = self.getOffsetNTPTime() def checkinCompetitor(self, idCompetitorEPC, idCompetitorBibNumber): ''' Method to be called once a competitor do a check-in. This is a callback method to be send to the reader. It sends a MQTT message to the broker :param idCompetitor: String with the ID of the competitor that the reader detected. ''' competitor = {} if (idCompetitorEPC != None): competitor["epc"] = idCompetitorEPC; if (idCompetitorBibNumber != None): competitor["bib"] = idCompetitorBibNumber; messageCheckin = { "checkpoint" : self.id , "timestamp" : self.getTimestamp(), "competitor" : competitor } topic = self.id + "/" + self.TOPIC_CHECKIN publish.single(topic, json.dumps(messageCheckin), hostname=self.mqttBrokerHost) print(topic + " topic to MQTT:") print(json.dumps(messageCheckin)) def execute(self): messageReady = { "checkpoint" : self.id , "timestamp" : self.getTimestamp() } topic = self.id + "/" + self.TOPIC_READY publish.single(topic, json.dumps(messageReady), hostname=self.mqttBrokerHost) print(topic + " topic to MQTT:") print(json.dumps(messageReady)) self.reader.initialize() self.reader.doInventory(self.checkinCompetitor) def getOffsetNTPTime(self): ''' Get timestamp from a NTP server and stores the offset with the internal clock. :return: (float) with the difference between the local clock and the NTP time (in seconds) ''' c = ntplib.NTPClient() response = c.request('europe.pool.ntp.org', version=3) # convert from seconds since 1900 to seconds since 1970 ntpUnixtime = response.tx_timestamp - 2208988800 timestampOffset = time.time() - ntpUnixtime; return timestampOffset def getTimestamp(self): ''' Returns the local time plus the offset registered at the beginning. :return: long with the current timestamp (unix time) ''' return int(time.time() + self.timestampOffset)
The key part of this code is the execution itself:
def execute(self): ... self.reader.doInventory(self.checkinCompetitor)
When the checkpoint is correctly setup, the reader is asked to start the inventory of runners. Once either a bibNumber (from a keyboard input) or a EPC (from the RFID reader) is detected the checkinCompetitor callback is executed. This method creates the message for the MQTT receivers that will contains the information about the competitor id.
The functionality of this specific checkpoint is implemented using the following main method:
# ... imports if __name__ == '__main__': reader = usb_keypad_reader.USBKeypadReader() checkpoint = checkpoint.Checkpoint('Keypad-1', reader, 'activioty.ddns.net') checkpoint.execute()
This approach may be extended to other checkin mechanisms such as bar-code readers or computer vision analyzers. Perhaps for the next release ;-)
0 notes
programmingbiters-blog · 7 years ago
Photo
Tumblr media
New Post has been published on http://programmingbiters.com/android-content-placeholder-animation-like-facebook-using-shimmer/
Android Content Placeholder Animation like Facebook using Shimmer
We normally use spinner loaders when the app wants to load the data from a network call. Instead of using the usual loaders, we can make the loading screen more interesting using Facebook’s Shimmer library. This library adds Shimmer effect on to any custom view that we define. You can notice this shimmer effect in Facebook’s mobile and desktop apps.
This article explains how to use the Shimmer library in your apps with an example of loading a list data from a JSON http call.
VIDEO DEMO
youtube
1. Facebook’s Shimmer Library
To get shimmer effect on any layout, you have to place your layout inside ShimmerFrameLayout. To start the animation, you have to call startShimmerAnimation() on ShimmerFrameLayout. That’s all, you can immediately notice the shimmer effect on your layout. You can find the additional documentation on the Shimmer’s page.
Below is the code snippet to get the Shimmer effect. First, place your layout inside ShimmerFrameLayout.
To start the animation, call startShimmerAnimation() from your activity.
ShimmerFrameLayout shimmerContainer = (ShimmerFrameLayout) findViewById(R.id.shimmer_view_container); shimmerContainer.startShimmerAnimation();
2. Sample JSON
To demonstrate this example, I have created a sample JSON that contains a list of recipes. This endpoint simulates the network delay by adding 2 sec delay before responding the JSON so that the Shimmer effect can be noticed.
https://api.androidhive.info/json/shimmer/menu.php
[ "id": 1, "name": "Salmon Teriyaki", "description": "Put the ginger and garlic into a bowl and mix with the soy sauce, maple syrup, mirin and a drizzle of olive oil", "price": 140, "chef": "Gordon Ramsay", "thumbnail": "https://api.androidhive.info/images/food/1.jpg", "timestamp": "2 min ago" , "id": 2, "name": "Grilled Mushroom", "description": "Combine butter, dill and garlic salt, brush over mushrooms.", "price": 150, "chef": "Ravi Tamada", "thumbnail": "https://api.androidhive.info/images/food/2.jpg", "timestamp": "5 min ago" ]
Let’s try the Shimmer library by creating a simple app.
3. Creating New Project
1. Create a new project in Android Studio from File ⇒ New Project and select Basic Activity from templates.
2. Add Shimmer dependency to your build.gradle and rebuild the project.
dependencies implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:26.1.0' // Shimmer implementation 'com.facebook.shimmer:shimmer:0.1.0@aar'
3. Add the below colors and dimens to respective files.
#d91248 #d91248 #3ad23e #dddddd #0c0c0c #1a1a1a #777 #777
16dp 50dp 8dp 16dp 10dp 15dp 12dp 11dp 15dp 13dp
4. Create a new layout xml file named recipe_placeholder_item.xml. In this file we define the placeholder layout using plain View elements. All the views will be placed similar to actual list items.
5. As the placeholder view is ready, let’s add it to our main activity layout. Open the layout file of your main activity i.e activity_main.xml and include the placeholder layout. We are including the placeholder layout three times to make it appear as list.
6. Open MainActivity.java and start the Shimmer animation by calling startShimmerAnimation() method in onResume(). We are also pausing the animation in onPause() when the activity is paused.
import com.facebook.shimmer.ShimmerFrameLayout; public class MainActivity extends AppCompatActivity private ShimmerFrameLayout mShimmerViewContainer; @Override protected void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mShimmerViewContainer = findViewById(R.id.shimmer_view_container); @Override public void onResume() super.onResume(); mShimmerViewContainer.startShimmerAnimation(); @Override public void onPause() mShimmerViewContainer.stopShimmerAnimation(); super.onPause();
Now if you run the app, you can see the below Shimmer animation.
3.1 Loading feed from JSON and hiding the Shimmer
Now as our Shimmer loader is ready, let’s see how to load the JSON feed in RecyclerView and hide the shimmer loader once the list is rendered. By following the remaining part of the article, you will understand how to implement the Shimmer effect in a real world app.
7. Open the build.gradle and add RecyclerView, Glide and Volley dependencies.
dependencies implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:26.1.0' // ... // Shimmer implementation 'com.facebook.shimmer:shimmer:0.1.0@aar' // RecyclerView implementation 'com.android.support:recyclerview-v7:26.1.0' // glide image library implementation 'com.github.bumptech.glide:glide:3.7.0' // volley http library implementation 'com.android.volley:volley:1.0.0' implementation 'com.google.code.gson:gson:2.6.2'
8. Create a class named MyApplication.java and extend the class from Application. This is a singleton class in which the Volley library will be initiated.
package info.androidhive.shimmer; /** * Created by ravi on 18/01/18. */ import android.app.Application; import android.text.TextUtils; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.toolbox.Volley; public class MyApplication extends Application public static final String TAG = MyApplication.class .getSimpleName(); private RequestQueue mRequestQueue; private static MyApplication mInstance; @Override public void onCreate() super.onCreate(); mInstance = this; public static synchronized MyApplication getInstance() return mInstance; public RequestQueue getRequestQueue() if (mRequestQueue == null) mRequestQueue = Volley.newRequestQueue(getApplicationContext()); return mRequestQueue; public void addToRequestQueue(Request req, String tag) // set the default tag if tag is empty req.setTag(TextUtils.isEmpty(tag) ? TAG : tag); getRequestQueue().add(req); public void addToRequestQueue(Request req) req.setTag(TAG); getRequestQueue().add(req); public void cancelPendingRequests(Object tag) if (mRequestQueue != null) mRequestQueue.cancelAll(tag);
9. Open AndroidManifest.xml and add the MyApplication class to tag. We also need INTERNET permission as we are going to make http calls.
10. Open activity_main.xml and add RecyclerView widget below the ShimmerFrameLayout.
11. Create a new class named Recipe.java and define the following variables. This is a POJO class used to serialize the JSON.
package info.androidhive.shimmer; /** * Created by ravi on 18/01/18. */ public class Recipe int id; String name; String description; double price; String thumbnail; String chef; String timestamp; public Recipe() public int getId() return id; public String getName() return name; public String getDescription() return description; public double getPrice() return price; public String getThumbnail() return thumbnail; public String getChef() return chef; public String getTimestamp() return timestamp;
12. Create a new xml layout named recipe_list_item.xml. This layout holds the actual list row with a thumbnail image and few TextViews.
13. We need another class to write the necessary adapter required for RecyclerView. Create a class named RecipeListAdapter.java and add below code.
package info.androidhive.shimmer; /** * Created by ravi on 18/01/18. */ import android.content.Context; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.bumptech.glide.Glide; import java.util.List; public class RecipeListAdapter extends RecyclerView.Adapter private Context context; private List cartList; public class MyViewHolder extends RecyclerView.ViewHolder public TextView name, description, price, chef, timestamp; public ImageView thumbnail; public MyViewHolder(View view) super(view); name = view.findViewById(R.id.name); chef = view.findViewById(R.id.chef); description = view.findViewById(R.id.description); price = view.findViewById(R.id.price); thumbnail = view.findViewById(R.id.thumbnail); timestamp = view.findViewById(R.id.timestamp); public RecipeListAdapter(Context context, List cartList) this.context = context; this.cartList = cartList; @Override public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) View itemView = LayoutInflater.from(parent.getContext()) .inflate(R.layout.recipe_list_item, parent, false); return new MyViewHolder(itemView); @Override public void onBindViewHolder(MyViewHolder holder, final int position) final Recipe recipe = cartList.get(position); holder.name.setText(recipe.getName()); holder.chef.setText("By " + recipe.getChef()); holder.description.setText(recipe.getDescription()); holder.price.setText("Price: ₹" + recipe.getPrice()); holder.timestamp.setText(recipe.getTimestamp()); Glide.with(context) .load(recipe.getThumbnail()) .into(holder.thumbnail); // recipe @Override public int getItemCount() return cartList.size();
14. Now we have everything in place. Open MainActivity.java and modify the code as shown below.
> fetchRecipes() method fetches the JSON by making Volley’s http call. The JSON is parsed using Gson serializer.
> Once the JSON is parsed and added to RecyclerView adapter, the list is rendered and ShimmerFrameLayout is hidden making the actual list visible on the screen.
package info.androidhive.shimmer; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.View; import android.widget.Toast; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonArrayRequest; import com.facebook.shimmer.ShimmerFrameLayout; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import org.json.JSONArray; import java.util.ArrayList; import java.util.List; public class MainActivity extends AppCompatActivity private static final String TAG = MainActivity.class.getSimpleName(); private RecyclerView recyclerView; private List cartList; private RecipeListAdapter mAdapter; private ShimmerFrameLayout mShimmerViewContainer; // URL to fetch menu json // this endpoint takes 2 sec before giving the response to add // some delay to test the Shimmer effect private static final String URL = "https://api.androidhive.info/json/shimmer/menu.php"; @Override protected void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mShimmerViewContainer = findViewById(R.id.shimmer_view_container); recyclerView = findViewById(R.id.recycler_view); cartList = new ArrayList<>(); mAdapter = new RecipeListAdapter(this, cartList); RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext()); recyclerView.setLayoutManager(mLayoutManager); recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL, 16)); recyclerView.setAdapter(mAdapter); // making http call and fetching menu json fetchRecipes(); /** * method make volley network call and parses json */ private void fetchRecipes() JsonArrayRequest request = new JsonArrayRequest(URL, new Response.Listener() @Override public void onResponse(JSONArray response) if (response == null) Toast.makeText(getApplicationContext(), "Couldn't fetch the menu! Pleas try again.", Toast.LENGTH_LONG).show(); return; List recipes = new Gson().fromJson(response.toString(), new TypeToken>() .getType()); // adding recipes to cart list cartList.clear(); cartList.addAll(recipes); // refreshing recycler view mAdapter.notifyDataSetChanged(); // stop animating Shimmer and hide the layout mShimmerViewContainer.stopShimmerAnimation(); mShimmerViewContainer.setVisibility(View.GONE); , new Response.ErrorListener() @Override public void onErrorResponse(VolleyError error) // error in getting json Log.e(TAG, "Error: " + error.getMessage()); Toast.makeText(getApplicationContext(), "Error: " + error.getMessage(), Toast.LENGTH_SHORT).show(); ); MyApplication.getInstance().addToRequestQueue(request); @Override public void onResume() super.onResume(); mShimmerViewContainer.startShimmerAnimation(); @Override public void onPause() mShimmerViewContainer.stopShimmerAnimation(); super.onPause();
I hope this article is pretty simple and explained very well about Shimmer library. If you have any queries, do post them in comments section below.
Hi there! I am Founder at androidhive and programming enthusiast. My skills includes Android, iOS, PHP, Ruby on Rails and lot more. If you have any idea that you would want me to develop? Let’s talk: [email protected]
(function(d, s, id) var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "http://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.9"; fjs.parentNode.insertBefore(js, fjs); (document, 'script', 'facebook-jssdk'));
قالب وردپرس
0 notes
nddnews · 8 years ago
Text
Pisca-pisca é um ótimo recurso decorativo de Natal
Pisca-pisca é um ótimo recurso decorativo de Natal
Especialista complementa que o acessório pode ser inserido ainda em vasos e garrafas, decorar quartos e escritórios O pisca-pisca é um grande curinga na decoração de Natal. Uma árvore sem esse recurso pode ficar sem graça, sem vida. De acordo com o arquiteto Fabiano Ravaglia, ele pode, inclus
Notícias Do Dia
Leia a postagem completa: http://www.noticiasdodia.info/2017/12/pisca-pisca-e-um-otimo-recurso-decorativo-de-natal/
0 notes
mulherama · 8 years ago
Text
New Post has been published on Mulherama
New Post has been published on https://mulherama.info/2017/11/juju-salimeni-mostra-resultado-de-preenchimento-labial-na-web/
Juju Salimeni mostra resultado de preenchimento labial na Web
‘Gosto de bocão e achei que estava faltando um pouquinho’, disse a musa fitness em uma rede social
Juju Salimeni fez preenchimento labial e mostrou o resultado no Stories, do Instagram, na noite desta terça-feira. “As mulheres perguntando o que eu fiz na boca, se eu coloquei algum tipo de preenchimento. Sim, mulherada, aumentei um pouquinho a boca, um pouquinho”, disse a musa fitness.
Juju disse que gostou do resultado e que não queria nada exagerado. “Eu amei. Fiquei bem satisfeita, achei que ficou bem proporcional, que não ficou nada exagerado. E eu gosto de bocão e achei que estava faltando um pouquinho”.
Recentemente, Juju Salimeni também fez outro procedimento estético. A assistente de palco do “Legendários” trocou suas próteses de silicone.
Juju Salimeni mostra resultado de preenchimento labial
Foto: Reprodução Internet
0 notes
sitedemulher · 8 years ago
Text
Fátima Bernardes posta foto romântica: ‘Quem sabe isso quer dizer amor’
Fátima Bernardes posta foto romântica: ‘Quem sabe isso quer dizer amor’
Apresentadora assumiu romance com Túlio Gadelha recentemente Fátima Bernardes postou no Instagram, na manhã desta segunda-feira, uma foto em que aparece andando de bicicleta com o novo namorado, Túlio Gadelha. A apresentadora e o rapaz assumiram o relacionamento recentemente e parecem estar bas
Site De Mulher
Leia a postagem completa: http://www.sitedemulher.net/2017/11/fatima-bernardes-posta-foto-romantica-quem-sabe-isso-quer-dizer-amor/
0 notes
esmaelsilva · 7 years ago
Text
Quando os humanos fazem guerra, animais também sofrem, diz ...
Quando os humanos fazem guerra, animais também sofrem, diz …
‘); } var _aep = _aep || []; (function(d, s, c) { var getTimestamp = function() { var date = new Date(); return (’00’ + date.getFullYear()).slice(-2) + (’00’ + date.getMonth()).slice(-2) + (’00’ + date.getDate()).slice(-2); }; _aep.push([‘tag’, ‘5a15ccc9f0b35f0004df2433’, { /* add optional custom config here */ }]); var f = d.createElement(s); f.src = (d.location.protocol == ‘https:’) ?…
View On WordPress
0 notes
jamilpr · 8 years ago
Text
How to Create a Slack Bot without using PoshBot.
If you run Windows 7 or Windows Server 2008 in your environment, PoshBot is not something you can use. This is a chat bot which connects to Slack’s API and retrieves the latest messages.
#Declare object of the Channel $MyBot = [PSCustomObject]@{ LastMessage = [decimal] 0 Channel = ‘A212’ #This needs to be set Token = 'token-1’ #This needs to be set Count = '10’ TempTimestamp = [decimal] 0 MyUserName = [string] “MyBot” MessageChannel = 'W11’ Trigger = ’@’ }
#Creates an array which contains the different channels you have. You can copy $MyBot for each channel.
$BotConfig = @() $BotConfig += $MyBot
#This is a bad name for this method, however, it gets the latest message’s timestamp.
Function GetTimeStamps ($COnfigData,$messages) { foreach ($item in $messages.messages) { if ($item.ts -gt $configdata.lastmessage) { if ($item.ts -gt $configdata.temptimestamp) { $configdata.temptimestamp = $item.ts } } } return $configdata }
Function GetMessage ($info) { $url = “https://slack.com/api/groups.history?token=” + $info.token + “&channel=” + $info.channel + “&pretty=1count=10” $data = Invoke-WebRequest $url -SessionVariable temp #Convert the data to an object $returnData = $data.Content | convertfrom-json return $returnData
} function NewActionMessage { [CmdletBinding()] param( [Parameter(Mandatory=$true)] [PSCustomObject]$Object, [Parameter(Mandatory=$true)] [PSCustomObject]$Message )
if ($object.trigger -like $message.message.substring(0,1) -and $message.message.substring(1) -like “help*”) { SendMessage -token $Object.Token -channel $Object.MessageChannel -opt_username $Object.MyUserName -messagecontent “Welcome to help” }
}
#This loop will run forever. do { #Loop through all your channels declared earlier. foreach ($Config in $BotConfig) { #Get all messages for the channel. $apimessages = GetMessage($Config) #Store the timestamp for the newest message $c = GetTimeStamps $Config $apimessages $Config.TempTimestamp = $c.TempTimestamp #if the latest message is not set, set it to the last message, therefore nothing will happen on start-up. if ($Config.LastMessage -lt 0.01) { $Config.LastMessage = $c.TempTimestamp } #Loop through all messages foreach ($i in $apimessages.messages) { $text = $I.text $user = $i.user $ts = $i.ts #If the timestamp of the messages pulled from the Slack API are newer than the last message the Bot saw when it last ran if ($ts -gt $Config.LastMessage -and $user -notlike $Config.MyUserName -and $user -ne $null -and $user -ne “”) { #Create an object with the message, user. $TempObject = [PSCustomObject]@{ Message = $text User = $user } $r = NewActionMessage -Object $Config -Message $TempObject } } #Set the newest message from this API call to the last message received. $Config.LastMessage = $c.TempTimestamp Start-Sleep 30 }
} while ($true)
The limitations of this chat bot are that on first run it will not do anything.
@Help is the only command which works
This chat bot calls makes many calls and needs to be created as a scheduled task.
0 notes
t-baba · 8 years ago
Photo
Tumblr media
Hello, Laravel? Communicating with PHP through SMS!
In this article, we will modify our Laravel-powered phone-capable weather forecast app so that it is accessible via SMS (text message) in addition to the voice telephone system. It is recommended you read the previous post if you haven't done so yet - it's a 10 minute read for an excellent outcome.
Note: If you're confused by the development environment we're using, it's Homestead Improved and you can learn more about it here, or go in detail by buying our book about PHP environments.
Adding Routes
To allow for SMS communication, we need some more routes. Open up the routes/web.php file and append the following code to it:
Route::group(['prefix' => 'sms', 'middleware' => 'twilio'], function () { Route::post('weather', 'SmsController@showWeather')->name('weather'); });
The prefix for the route is sms, so that routes will have a path like /sms/weather, as the one in the example. This is the only route we need for SMS, as Twilio will call the same route over and over again. Twilio will access it via HTTP POST. We could also do this without the prefix, but it's more flexible this way if we decide to add more functionality to the SMS side later.
Service Layer
Next, we'll modify the service we wrote previously. Open up the app/Services/WeatherService.php file and remove the current getWeather method, then replace it with the one below:
public function getWeather($zip, $dayName, $forSms = false) { $point = $this->getPoint($zip); $tz = $this->getTimeZone($point); $forecast = $this->retrieveNwsData($zip); $ts = $this->getTimestamp($dayName, $zip); $tzObj = new \DateTimeZone($tz->timezoneId); $tsObj = new \DateTime(null, $tzObj); $tsObj->setTimestamp($ts); foreach ($forecast->properties->periods as $k => $period) { $startTs = strtotime($period->startTime); $endTs = strtotime($period->endTime); if ($ts > $startTs and $ts < $endTs) { $day = $period; break; } } $weather = $day->name; $weather .= ' the ' . $tsObj->format('jS') . ': '; $response = new Twiml(); if ($forSms) { $remainingChars = 140 - strlen($weather); if (strlen($day->detailedForecast) > $remainingChars) { $weather .= $day->shortForecast; $weather .= '. High of ' . $day->temperature . '. '; $weather .= $day->windDirection; $weather .= ' winds of ' . $day->windSpeed; } else { $weather .= $day->detailedForecast; } $response->message($weather); } else { $weather .= $day->detailedForecast; $gather = $response->gather( [ 'numDigits' => 1, 'action' => route('day-weather', [], false) ] ); $menuText = ' '; $menuText .= "Press 1 for Sunday, 2 for Monday, 3 for Tuesday, "; $menuText .= "4 for Wednesday, 5 for Thursday, 6 for Friday, "; $menuText .= "7 for Saturday. Press 8 for the credits. "; $menuText .= "Press 9 to enter in a new zipcode. "; $menuText .= "Press 0 to hang up."; $gather->say($weather . $menuText); } return $response; }
This function is very similar to the old one. The only difference is that it takes into consideration that the weather request might be coming form a telephone device via SMS, so it makes sure that the weather forecast isn't too long and tries to limit it to less than 140 characters. The response for SMS is still TwiML, just formatted for SMS.
Continue reading %Hello, Laravel? Communicating with PHP through SMS!%
by Christopher Thomas via SitePoint http://ift.tt/2s4qHpk
0 notes
mbaljeetsingh · 8 years ago
Text
Hello, Laravel? Communicating with PHP through Phone Calls!
Twilio is a SaaS application which enables developers to build telephone applications using web technologies. In this two-part series, we will leverage Twilio to build a weather forecast app that is accessed using the telephone system. The backend will be written with the Laravel framework (an exploratory video course is available for purchase here, or in the form of written tutorials here).
In this part, we will create a simple program that will allow a user to call a phone number that we buy from Twilio, enter a zipcode, and receive the current weather forecast. The user can also get the weather for any day of the week via the voice menu prompts. In the second part of this series, we will leverage what was built in this article to allow the user to interact with the app via SMS (text message).
Prerequisites
Development Environment
This article assumes Homestead Improved is installed. It is not necessary to use it, but the commands might differ slightly if you use a different environment. If you are not familiar with Homestead and want to produce similar results as this article aims to produce, please visit this SitePoint article that shows how to set up Homestead, and if you need a crash course in Vagrant, please see this post. Additionally, if this whets your appetite and you feel like exploring PHP development environments in depth, we have a book about that available for purchase.
Dependencies
We will create a new Laravel project and then add the Twilio PHP SDK and Guzzle HTTP client library to the project:
cd ~/Code composer create-project --prefer-dist laravel/laravel Laravel 5.4.* cd Laravel composer require "twilio/sdk:^5.7" composer require "guzzlehttp/guzzle:~6.0"
Development
Let's go through all the steps, one by one.
Routes
Open up the routes/web.php file and add the following ones:
Route::group(['prefix' => 'voice', 'middleware' => 'twilio'], function () { Route::post('enterZipcode', 'VoiceController@showEnterZipcode')->name('enter-zip'); Route::post('zipcodeWeather', 'VoiceController@showZipcodeWeather')->name('zip-weather'); Route::post('dayWeather', 'VoiceController@showDayWeather')->name('day-weather'); Route::post('credits', 'VoiceController@showCredits')->name('credits'); });
In this app, all requests will be under the /voice path. When Twilio first connects to the app, it will go to /voice/enterZipcode via HTTP POST. Depending on what happens in the telephone call, Twilio will make requests to other endpoints. This includes /voice/zipcodeWeather for providing today's forecast, /voice/dayWeather, for providing a particular day's forecast, and /voice/credits for providing information on where the data came from.
Service Layer
We are going to add a service class. This class will hold a lot of the business logic that will be shared between the voice telephone app and the SMS app.
Create a new sub-folder called Services inside the app folder. Then, create a file called WeatherService.php and put the following content into it:
<?php namespace App\Services; use Illuminate\Support\Facades\Cache; use Twilio\Twiml; class WeatherService { }
This is a large file in the project, so we will build it piece by piece. Put the following pieces of code in this section inside our new service class:
public $daysOfWeek = [ 'Today', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ];
We will use this array to map a day of the week to a number; Sunday = 1, Monday = 2, etc.
public function getWeather($zip, $dayName) { $point = $this->getPoint($zip); $tz = $this->getTimeZone($point); $forecast = $this->retrieveNwsData($zip); $ts = $this->getTimestamp($dayName, $zip); $tzObj = new \DateTimeZone($tz->timezoneId); $tsObj = new \DateTime(null, $tzObj); $tsObj->setTimestamp($ts); foreach ($forecast->properties->periods as $k => $period) { $startTs = strtotime($period->startTime); $endTs = strtotime($period->endTime); if ($ts > $startTs and $ts < $endTs) { $day = $period; break; } } $response = new Twiml(); $weather = $day->name; $weather .= ' the ' . $tsObj->format('jS') . ': '; $weather .= $day->detailedForecast; $gather = $response->gather( [ 'numDigits' => 1, 'action' => route('day-weather', [], false) ] ); $menuText = ' '; $menuText .= "Press 1 for Sunday, 2 for Monday, 3 for Tuesday, "; $menuText .= "4 for Wednesday, 5 for Thursday, 6 for Friday, "; $menuText .= "7 for Saturday. Press 8 for the credits. "; $menuText .= "Press 9 to enter in a new zipcode. "; $menuText .= "Press 0 to hang up."; $gather->say($weather . $menuText); return $response; }
The getWeather method takes a zipcode with the day of the week and crafts the text of a weather forecast. First, it figures out the reference time for the day requested, and then looks up the weather forecast by doing a foreach over the array of forecast data. After that, it returns a Voice TwiML response. Below is a sample of what is returned:
<?xml version="1.0" encoding="UTF-8"?> <Response> <Gather numDigits="1" action="/voice/dayWeather"> <Say> This Afternoon the 31st: Sunny, with a high near 72. South southwest wind around 8 mph. Press 1 for Sunday, 2 for Monday, 3 for Tuesday, 4 for Wednesday, 5 for Thursday, 6 for Friday, 7 for Saturday. Press 8 for the credits. Press 9 to enter in a new zipcode. Press 0 to hang up. </Say> </Gather> </Response>
The <Gather> tag tells Twilio to expect input from the user's keypad. The numDigits attribute says how many digits to expect. The action attribute says what endpoint to contact next.
protected function retrieveNwsData($zip) { return Cache::remember('weather:' . $zip, 60, function () use ($zip) { $point = $this->getPoint($zip); $point = $point->lat . ',' . $point->lng; $url = 'http://ift.tt/2siEbBl' . $point . '/forecast'; $client = new \GuzzleHttp\Client(); $response = $client->request('GET', $url, [ 'headers' => [ 'Accept' => 'application/geo+json', ] ]); return json_decode((string)$response->getBody()); }); }
The retrieveNwsData method gets the weather forecast data. First, the method checks to see if a copy of the zipcode's weather forecast is in cache. If not, then the Guzzle HTTP client is used to make an HTTP GET request to the National Weather Service's (NWS) API endpoint http://ift.tt/2siJ4Kk. To get the geographic point of the zipcode, a call is made to the getPoint method before doing the request to the weather API. The response from the API endpoint is the weather forecast in GeoJSON format. The forecast is for every day and night for a week (with some exceptions we will discuss later); 14 entries in all. We cache the API response for an hour because making the request is slow, plus we do not want to hit the government servers too frequently and get banned.
protected function getPoint($zip) { return Cache::remember('latLng:' . $zip, 1440, function () use ($zip) { $client = new \GuzzleHttp\Client(); $url = 'http://ift.tt/1p5neFv'; $response = $client->request('GET', $url, [ 'query' => [ 'postalcode' => $zip, 'countryBias' => 'US', 'username' => env('GEONAMES_USERNAME') ] ]); $json = json_decode((string)$response->getBody()); return $json->postalCodes[0]; }); }
The getPoint method maps a zipcode to a geographic point. This is done by using the GeoNames API. The results are cached for a day because using the API is slow.
protected function getTimeZone($point) { $key = 'timezone:' . $point->lat . ',' . $point->lng; return Cache::remember($key, 1440, function () use ($point) { $client = new \GuzzleHttp\Client(); $url = 'http://ift.tt/1C9XM7m'; $response = $client->request('GET', $url, [ 'query' => [ 'lat' => $point->lat, 'lng' => $point->lng, 'username' => env('GEONAMES_USERNAME') ] ]); return json_decode((string) $response->getBody()); }); }
The getTimeZone method is used to get the timezone that a geographic point resides inside. The GeoNames API is also used and the results are cached for a day for the same reasons.
Continue reading %Hello, Laravel? Communicating with PHP through Phone Calls!%
via SitePoint http://ift.tt/2siIbSa
0 notes
mundolatinomedia · 7 years ago
Text
Chanceler da China nega acusações americanas de roubo de tecnologia
Chanceler da China nega acusações americanas de roubo de tecnologia
'); } var _aep = _aep || []; (function(d, s, c) { var getTimestamp = function() { var date = new Date(); return ('00' + date.getFullYear()).slice(-2) + ('00' + date.getMonth()).slice(-2) + ('00' + date.getDate()).slice(-2); }; _aep.push(['tag', '5a15ccc9f0b35f0004df2433', { /* add optional custom config here */ }]); var f = d.createElement(s); f.src = (d.location.protocol == 'https:') ?…
View On WordPress
0 notes