query_id stringlengths 4 64 | query_authorID stringlengths 6 40 | query_text stringlengths 66 72.1k | candidate_id stringlengths 5 64 | candidate_authorID stringlengths 6 40 | candidate_text stringlengths 9 101k |
|---|---|---|---|---|---|
04aa08389b0115e757b5e95183dd8f61d074379d1d34442436fb1bc64a07533c | ['e8ab282bdbf34be78133328f43d35101'] | I think it's a very basic thing but I'm still not sure what happens.
For example I have a SeekBar, when I start to change its value I want a TextView to be hidden, but what happens if it is already hidden and I try to hide it?, Will that line of code be skipped or will it be executed?
For example, is it more advisable to do this ?:
public void onStartTrackingTouch(SeekBar seekBar) {
if (textView.getVisibility() == View.VISIBLE){
textView.setVisibility(View.GONE);
}
}
Or is it better to do this?
public void onStartTrackingTouch(SeekBar seekBar) {
textView.setVisibility(View.GONE);
}
I know that the result of the above codes is the same, but I want to do a good practice
| 55190d0940571c5c9a8b51a6a2cdabdb96188a956523454b031b9667ac33b14b | ['e8ab282bdbf34be78133328f43d35101'] | In my Banner design:
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:visibility="gone"
app:adSize="BANNER"
app:adUnitId="ca-app-pub-3940256099942544/<PHONE_NUMBER>"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</com.google.android.gms.ads.AdView>
If it is not premium mode I call this method
private void showBanner(){
MobileAds.initialize(this, new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(InitializationStatus initializationStatus) {
}
});
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
mAdView.setVisibility(View.VISIBLE);
mAdView.setAdListener(new AdListener(){
@Override
public void onAdLoaded() {
super.onAdLoaded();
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
mAdView.setLayoutParams(layoutParams);
mAdView.setVisibility(View.VISIBLE);
}
@Override
public void onAdFailedToLoad(LoadAdError loadAdError) {
super.onAdFailedToLoad(loadAdError);
mAdView.setVisibility(View.GONE);
}
});
}
first I show the banner occupying 60dp assigned in design, I have added a listener so that the space is hidden if the banner cannot be loaded, but if the banner is loaded it assigns in height and width WRAP_CONTENT and shows it
|
f469afec59564b64ce347e41c192743d335cd2627776e96ebf94c7af83f4a70b | ['e8b5730133d04ff68d125e6ac6602906'] | TM did work until I updated to 10.15.4. I removed the TM drive in the process of fixing the error, now the TM application doesn't see the drive. The "Sharing & Permissions" picture is the finder view of my sparse bundle folder on TM. I'm baffled because finder shows permissions one way and terminal shows another. | f33f5224cad53f410684821fb5da815c0617ff4a592d01c05f252899502d5e64 | ['e8b5730133d04ff68d125e6ac6602906'] | I use time machine for backups. I just updated to Catalina 10.15.4 from Catalina 10.15.3 and don't have permission for backups, unknown user is the only user that has read/write permissions. How do I correct this problem ? I've searched and tried a few answers but nothing seems to work. I use the terminal to check permissions of the directories/files and it shows that my user is the owner.
|
6dc251778645564649daf2cda993831f9aad9b4820965d20743e72a781df5b40 | ['e8be0b69881f4f3dad24db3c9553a48e'] | I have the following code and am looking to give my Countdown timer a title. Inside the bar, right above the boxes that give the time remaining. Would like it to be easy to edit font, size and spacing across. Having trouble doing so.
It also seems like when publishing this code, the padding for the variables: days, hours, mins, and secs get pushed down. Not centered under the boxes and the edge of the bottom of the countdown timer.
var target_date = new Date("Aug 30, 2018 20:30:00").getTime(); // set the countdown date
var days, hours, minutes, seconds; // variables for time units
var countdown = document.getElementById("tiles"); // get tag element
getCountdown();
setInterval(function() {
getCountdown();
}, 1000);
function getCountdown() {
// find the amount of "seconds" between now and target
var current_date = new Date().getTime();
var seconds_left = (target_date - current_date) / 1000;
days = pad(parseInt(seconds_left / 86400));
seconds_left = seconds_left % 86400;
hours = pad(parseInt(seconds_left / 3600));
seconds_left = seconds_left % 3600;
minutes = pad(parseInt(seconds_left / 60));
seconds = pad(parseInt(seconds_left % 60));
// format countdown string + set tag value
countdown.innerHTML = "<span>" + days + "</span><span>" + hours + "</span><span>" + minutes + "</span><span>" + seconds + "</span>";
}
function pad(n) {
return (n < 10 ? '0' : '') + n;
}
body {
font: normal 13px/20px Arial, Helvetica, sans-serif;
word-wrap: break-word;
color: #eee;
}
#countdown {
/*bar*/
width: 232.5px;
/*changed*/
height: 56px;
/*changed*/
text-align: center;
background: #222;
background-image: -webkit-linear-gradient(top, #264033, #feb330, #feb330, #264033);
background-image: -moz-linear-gradient(top, #222, #333, #333, #222);
background-image: -ms-linear-gradient(top, #222, #333, #333, #222);
background-image: -o-linear-gradient(top, #222, #333, #333, #222);
border: 1px solid #111;
border-radius: 5px;
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.6);
margin: auto;
padding: 12px 0;
/*changed*/
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
#countdown:before {
/*handles*/
content: "";
width: 4px;
/*changed*/
height: 32.5px;
/*changed*/
background: #444;
background-image: -webkit-linear-gradient(top, #264033, #264033, #264033, #264033);
/*changed*/
background-image: -moz-linear-gradient(top, #555, #444, #444, #555);
background-image: -ms-linear-gradient(top, #555, #444, #444, #555);
background-image: -o-linear-gradient(top, #555, #444, #444, #555);
border: 1px solid #111;
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
display: block;
position: absolute;
top: 24px;
/*changed*/
left: -5px;
/*changed*/
}
#countdown:after {
/*handles*/
content: "";
width: 4px;
/*changed*/
height: 32.5px;
/*changed*/
background: #444;
background-image: -webkit-linear-gradient(top, #264033, #264033, #264033, #264033);
/*changed*/
background-image: -moz-linear-gradient(top, #555, #444, #444, #555);
background-image: -ms-linear-gradient(top, #555, #444, #444, #555);
background-image: -o-linear-gradient(top, #555, #444, #444, #555);
border: 1px solid #111;
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
display: block;
position: absolute;
top: 24px;
/*changed*/
right: -5px;
}
#countdown #tiles {
position: relative;
z-index: 1;
}
#countdown #tiles>span {
/*box*/
width: 46px;
/*changed*/
max-width: 46px;
/*changed*/
font: bold 24px 'Droid Sans', Arial, sans-serif;
/*changed*/
text-align: center;
color: #000000;
/*color of numbers*/
/*changed*/
background-color: #ddd;
background-image: -webkit-linear-gradient(top, #111, #eee);
/*color of box*/
/*changed*/
background-image: -moz-linear-gradient(top, #bbb, #eee);
background-image: -ms-linear-gradient(top, #bbb, #eee);
background-image: -o-linear-gradient(top, #bbb, #eee);
border-top: 1px solid #fff;
/*top border of box*/
/*changed*/
border-left: 1px solid #fff;
/*left border of box*/
/*changed*/
border-right: 1px solid #fff;
/*right border of box*/
/*changed*/
border-bottom: 1px solid #fff;
/*bottom border of box*/
/*changed*/
border-radius: 3px;
box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.7);
margin: 0 3.5px;
/*changed*/
padding: 9px 0;
/*changed*/
display: inline-block;
position: relative;
}
#countdown #tiles>span:before {
/*mini-handles*/
content: "";
width: 100%;
height: 13px;
background: #000000;
/*changed*/
display: block;
padding: 0 3px;
position: absolute;
top: 41%;
left: -3px;
z-index: -1;
}
/* #countdown #tiles>span:after {
content: "";
width: 100%;
height: 1px;
background: #eee;
border-top: 1px solid #333;
display: block;
position: absolute;
top: 48%;
left: 0;
} /*line through middle*/
#countdown .labels {
/*words*/
width: 100%;
height: 12.5px;
/*changed*/
text-align: center;
position: absolute;
bottom: 8px;
}
#countdown .labels li {
/*words*/
width: 51px;
/*changed*/
font: bold 10px 'Droid Sans', Arial, sans-serif;
color: #ffffff;
/*changed*/
text-shadow: 1px 1px 0px #000;
text-align: center;
text-transform: uppercase;
display: inline-block;
}
<div id="countdown">
<div id='tiles'></div>
<div class="labels">
<li>Days</li>
<li>Hours</li>
<li>Mins</li>
<li>Secs</li>
</div>
</div>
| 9fa50a54ca0a6e18d027518a5257fc7591dc693fee18e3935382ff02f024194b | ['e8be0b69881f4f3dad24db3c9553a48e'] | Below is code that once hovered over the shape words will appear behind. Having two problems here:
1. If I make the font small (24px), the dark grey will not cover the whole shape.
2. I want to include words with the hover, e.g. I want it to display information on the shape before hovering, then fade away with the shape to show the new info behind it. Like a name fading away to give a bio.
I used w2schools to compile this: https://www.w3schools.com/code/tryit.asp?filename=FT2LEOI9SQQN
<html>
<div id="box">
<div id="overlay">
<span id="plus">Hello<br>Hi</span>
</div>
</div>
<style>
body {
background: #e7e7e7;
}
#box {
width: 300px;
height: 200px;
box-shadow: inset 1px 1px 40px 0 rgba(0, 0, 0, 0.45);
border-bottom: 2px solid #fff;
border-right: 2px solid #fff;
margin: 5% auto 0 auto;
background-size: cover;
border-radius: 5px;
overflow: hidden;
}
#overlay {
background: rgba(0, 0, 0, 0.75);
text-align: center;
padding: 45px 0 66px 0;
opacity: 0;
-webkit-transition: opacity 0.25s ease;
-moz-transition: opacity 0.25s ease;
}
#box:hover #overlay {
opacity: 1;
}
#plus {
font-family: Helvetica;
font-weight: 900;
color: rgba(255, 255, 255, 0.85);
font-size: 24px;
}
</style>
</html>
|
1007ba2a644220f04650b7e6ac3e666b073caee8ea2f1663a0964f5b9781c844 | ['e8df29d5c2a64dd1a4f5ed78976f9796'] | I am getting error "ORA-01428: argument '0' is out of range".
Subject in question is :
regexp_substr(ltrim(pn.pname),'\d+',INSTR(ltrim(pn.pname),'REFERENCE ID='))
when i am scrolling for more records it is giving that error.
example :
pname regexp value
FragIT<REFERENCE ID="6998" 6998
TYPE="trademark"/> MicroSpin
i am using total query like this :
SELECT pname,
regexp_substr(ltrim(pn.sys_name_text),'\d+',INSTR(ltrim(pn.sys_name_text),
'REFERENCE ID=')) comm from products p
left join product_names pn using(product_id)
where pname like '%trademark%' and language_id = 1
and regexp_count(pname,'trademark') <= 1
Here refrence tag may come more than once thats why putted last condition.
can you please help on this.
| 871ac6cf6fa212225d2761ed9910dc40255ba153ef9b0c314d87368f6cd0b7dc | ['e8df29d5c2a64dd1a4f5ed78976f9796'] | i am getting data from csv and storing in data in hash.From there i want to provide key and based on that key i want to get all values of Hash.There can be duplicate key that's i want all values of hash .
for ex :
**SpecID Note_Text**
300000111166 LDPE Bottle/Jar
300000111166 Poly-lined Steel Drum
300000057768 Amber Glass Bottle/Jar
Now if i give key : 300000111166
i should get values : LDPE Bottle/Jar,Poly-lined Steel Drum.How it can be done.
|
9f6da975f4ad7227fc9c50c214d7f05f0eaa52f6c1755463cb53b42ff31fc3b3 | ['e8f715ef53ed47898d0031b242e80656'] | I'm trying to implement JWT authentication on my asp.net core webAPI as simply as possible.
I don't know what i'm missing but it's always returning 401 even with the proper bearer token.
here is my configureServices code
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(x =>
{
x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
}).AddJwtBearer(
x =>
{
x.RequireHttpsMetadata = false;
x.SaveToken = true;
x.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuerSigningKey = true,
IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes("A_VERY_SECRET_SECURITY_KEY_FOR_JWT_AUTH")),
ValidateAudience = false,
ValidateIssuer = false,
};
}
);
services.AddControllers();
services.AddDbContext<dingdogdbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("dingdogdbContext")));
}
and this is how I'm generating token
[AllowAnonymous]
[HttpPost("/Login")]
public ActionResult<User> Login(AuthModel auth)
{
var user = new User();
user.Email = auth.Email;
user.Password = auth.Password;
//var user = await _context.User.SingleOrDefaultAsync(u=> u.Email == auth.Email && u.Password==auth.Password);
//if(user==null) return NotFound("User not found with this creds");
//starting token generation...
var tokenHandler = new JwtSecurityTokenHandler();
var seckey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes("A_VERY_SECRET_SECURITY_KEY_FOR_JWT_AUTH"));
var signingCreds = new SigningCredentials(seckey, SecurityAlgorithms.HmacSha256Signature);
var token = tokenHandler.CreateToken(new SecurityTokenDescriptor
{
Subject = new System.Security.Claims.ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, user.Id.ToString()) }),
SigningCredentials = signingCreds,
Expires = DateTime.UtcNow.AddDays(7),
});
user.Token = tokenHandler.WriteToken(token);
return user;
}
And I added app.useAuthorization() very after the app.useRouting().
when i'm sending POST request to /Login I'm getting the token. but when I'm using the token in for querying any other endpoint using postman(added the token in authorization/JWT in postman) getting 401 unauthorized every time.
is there anything I'm missing still?
| 7829dc76266a996486add1fbbeb7ba8ec0c33bdb62d7c5a3692a419fbe63d0ec | ['e8f715ef53ed47898d0031b242e80656'] | I am trying the mobX State management for flutter. But whenever I am updating my @observable State directly rather than calling an @action decorated method it is throwing 'MobXException'
Below code will will give you a proper idea.
counter.dart
import 'package:mobx/mobx.dart';
part 'counter.g.dart';
class Counter = CounterBase with _$Counter;
abstract class CounterBase implements Store {
@observable
int value = 0;
@action
void increment() {
value++;
}
}
main.dart
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import './counter.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Counter",
home: CounterExample(),
);
}
}
class CounterExample extends StatelessWidget {
final _counter = Counter();
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: const Text('Counter'),
),
body: Center(
child: Observer(
builder: (_) => Text(
'${_counter.value}',
style: const TextStyle(fontSize: 50),
)),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
// _counter.increment(); // WORKING !!
_counter.value = _counter.value+1; // NOT WORKING !!
},
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
using the increment method is working but why even for some simple state change I need to make another method? why the generated setter is not sufficient?
|
3e1f9149612a4bf97d9d16a24dd4e9bcc4ac8401a86bcd783453fbcb94fe5709 | ['e900e64513d64e898d5a42bdcc7fc800'] | First make sure you have embedded external js file using script tag in current page and if it is not then please embed it and check. If file is embedded then just change following in your HTML code
<a href="#" onclick="deleteTwitt();" class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-trash"></span> Delete</a>
Here I just removed "javascript:void(0)" from href of anchor tag. Still if it's does not work then let me know.
| 737775b1570ce2c8e6f27f8e9c5fca4186ea19e628520f0244307ef18525b4b8 | ['e900e64513d64e898d5a42bdcc7fc800'] | I have an issue with mongoDb mapReduce. I'm doing aggregation of a collection that contain millions of mongoDB documents and output of that aggregated documents are storing in other collection. I'm using cron job to aggregate all documents that run every hour and it works fine. Approximately cron job takes 10 minutes to aggregate all documents. But while aggregation is running using mapReduce and at same time other API call gets timeout because mapReduce talking place in whole memory and API call does not get memory to read / write data from other mongoDB collections.
So, I would like to know from you guys, Is there any way to set uses memory limit for mongoDB mapReduce? So other API call can read / write documents and response within timeout period.
I'm running on Mongolab "M1" cluster with 1.7 GB RAM and 40 GB SSD block storage.
I would like to invite everyone to help me and figure out this issue.
Thanks in advance.
|
b96bf55854ff5224a3a938e3323c355fef986bd50b0fe16ba356f3aa5eaab391 | ['e90d014cd92e49859540e5bc76109373'] | Prepare some patterns and do tests with all of them with multiple game testers (or just some friends) multiple times per pattern (e.g. 6 times per pattern). For each pattern, record the success rate and the learning rate (e.g. average success rate first and second half of the test). Also let the testers rate the boss movement pattern as "too easy", "easy", "okay", "harder", "hard", "too hard", "nearly impossible".
The preparation of the patterns could be done by once controlling the boss yourself like the player character and record the actions. Implement some kind of "arena" where you directly enter the boss fight and one can control/record the boss. This way your boss will probably become more "natural", that means less "programmatic".
| cc14519feff770632a1884e79c2b6f69e23d8ba8f7f982659a4dd1fbaf1ebf16 | ['e90d014cd92e49859540e5bc76109373'] | So in what context are you using FDT? Assuming this is running in Eclipse you would just need to specify some arguments to the mxmlc compiler as part of your build process. For example...
$ mxmlc Main.as -default-size 100 200
Where 'Main.as' is your entry point AS3 file, '100' is the width, '200' is the height. MXMLC defaults the output SWF to the same name as your input class. So in this example it would publish as SWF called 'Main.swf', but that is configurable as well.
Here is a good Adobe resource for the mxmlc command line arguments: Adobe MXMLC docs
HTH
|
906827044161611796f8e85d4c7a7bcaf7179efa2fb3d7fa567cdaaebb221da9 | ['e915deee70154d45b724db58eb6862e8'] | I have a hash that contains numbers as such:
{0=>0.07394653730860076, 1=>0.<PHONE_NUMBER>, 2=>0.07398647083461522}
it needs to be converted into an array like:
[[0, 0.07394653730860076], [1, 0.<PHONE_NUMBER>], [2, 0.07398647083461522]]
i tried my hash.values which gets me:
[0.07398921877505593, 0.07400253683443543, 0.07402917535044515]
I have tried multiple ways but i just started learning ruby.
| 12bb823a361f61fe4b1ae079e6cd85a4f45a450f322fff57b8610b318b956a3c | ['e915deee70154d45b724db58eb6862e8'] | So i have been working in this:(http://jsfiddle.net/2phuW/5/) for the last couple hours.
Could anyone help me out to figure out the following:
1) in the source sortable the abbreviation <PERSON>, ura, or mox needs to be shown
2) when the target is filled, :params[:ready] = true
3) when the target is filled the following code updates accordingly
<ul>
<li><i class="icon-edit"></i> Not ready </li>
<li><i class="icon-check"></i> Ready </li>
</ul>
4) when the target is filled, :params[:comp] gets the sorted elements of the target as an array: ie-> [:wat,:ura,:mox,:wat,...]
Thanks in advance
|
a2e4b190f702beb87a1743fc60a59a723ff8ed14d71cafe6bf27d535cb8a5814 | ['e918d7d44bd34a10b18e01e79071eea0'] | React-google-chart works well in development but it throws below error after build deployed in server.
VM565 2.351f67d9.chunk.js:2 Refused to load the script 'https://www.gstatic.com/charts/loader.js' because it violates the following Content Security Policy directive: "script-src 'self' https://ssl.google-analytics.com". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.
I have tried
"content_security_policy": "script-src 'self' https://maps.googleapis.com https://maps.gstatic.com; object-src 'self'" in manifest file
and
<meta http-equiv="Content-Security-Policy"
content="default-src 'self' data: gap: ws: ;
style-src 'self' https: *.google-analytics.com;
script-src 'self' https: *.google-analytics.com;
media-src 'none';
font-src *;
connect-src *;
img-src 'self' data: content: https: *.google-analytics.com;">
in index.html file
but none worked. May i know what i missing ? thanks
| 807293dee30020706902e34a38008d55df5575700f629d032b43477dc31c737b | ['e918d7d44bd34a10b18e01e79071eea0'] | The below code not returning amazon s3 content, it works when console the data value.
I have tried declare variable outside function and tried to return from function still, not works
const getMeridianToken1 = () =>{
s3 = new aws.S3();
// Create the parameters for calling listObjects
var bucketParams = {
Bucket: 'bucket-name',
Key: 'access_token.json'
};
// Call S3 to obtain a list of the objects in the bucket
s3.getObject(bucketParams, function(err, data) {
if (!err) {
var result = JSON.parse(data.Body.toString());
console.log("working here---",result.access_token);
return result.access_token; //this is not returning
}
});
//return JSON.parse(data.Body.toString()); //if hard code here it works, if i return s3 conteent the data variable not available here
}
console.log("not working",getMeridianToken1);
|
75a0bb99fb6656d38998615a4347fdca2722a6e5eac8c86d26ea1497e0f88c81 | ['e91a2ecad08a487b8eb50e4c28ad45ca'] | I'm thinking of storing permissions to users that I locate via cache management. This is kind of what that looks like:
function doGet() {
//upon opening the web page check if user exists:
var cache = CacheService.getUserCache();
var user = Session.getActiveUser().getEmail();
var value = cache.get(user);
//value is null only if user DNE in cache services
if(value === null || JSON.parse(cache.get(user)).access == false){
//instantiate user in cache services with restricted permissions
var permissions ={
"access": false,
};
cache.put(user,JSON.stringify(permissions), 30*60); //key, value, expiration date in seconds
Logger.log(`${user} is unauthorized`)
//open authorization page for uninstantiated users
return HtmlService.createHtmlOutputFromFile('Auth');
}
else if(JSON.parse(cache.get(user)).access == true){
return HtmlService.createHtmlOutputFromFile('Index');
}
}
function newPage(page) {
return HtmlService.createHtmlOutputFromFile(page).getContent()
}
Basically, I'm checking if a user is already in the cache then allocating permissions. Depending on your permissions you are redirected to a different part of the web app.
However, I recently realized that using cache could be a security issue depending on where the cache is stored and the google apps script documentation is not specific about whether the cache is stored on the user or if it is stored on the server. The documentation just says, "Gets the cache instance scoped to the current user and script. User caches are specific to the current user of the script. Use these to store script information that is specific to the current user" in regard to getUserCache()--the property I'm relying on in this script.
The main reason I wanted to use user cache is that I can easily set expiration dates on sessions. Does anyone know a way that I could possibly check where the cache data is stored? Thank you.
| c4d2fb60721473e104f34fb8ba1871be4950ddd19e5c9a5fafb6dd1f6efe7b4c | ['e91a2ecad08a487b8eb50e4c28ad45ca'] | I've been looking into using cookies to create sessions and keep track of user privileges.
So, I made some basic code for a web app where you click a button, and the active user email is accessed.
Here is the google script (Code.gs):
function doGet(){
return HtmlService.createHtmlOutputFromFile('Index');
}
function getUser(){
var email = Session.getActiveUser().getEmail();
return email;
}
Here is the HTML script (Index.html):
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<button onclick="recordUser()">Click me</button>
<script>
function recordUser(){
google.script.run.withSuccessHandler(function(email){
alert(email+ " is the user email.");
}).getUser();
}
</script>
</body>
</html>
This is the HTML output
"Authorization is required to perform that action." To my understanding, this means that every user of the web app has to somehow provide authorization to the google script allowing email access. So, I tried making the script have the scope of email info. This doesn't really work--and I didn't really expect it too.
This is what my project properties > scopes look like
So, is there any way to access active users via asking for authorization or through some workaround? Thank you.
|
4555dce1237b626afc9110ca713a2cde3b6cb5a36f8f9632756311d8850fb5ff | ['e91f59aefbb44cea98b9f8c4b065551f'] | Had similar issue myself. Converted a VS2005 project to VS2010.
I was using the option, Linker -> Manifest File -> Additional Manifest Dependencies: type='win32' name='Microsoft.Windows.Common-Controls' version='<IP_ADDRESS>' processorArchitecture='' publicKeyToken='6595b64144ccf1df' language=''
The conversion garbled it into type=%27win32%27...etc
Fixing this option to the correct format, type='win32'..etc resolved the issue. But not before I accidentally used the format, type=win32...etc and received the same error.
| bce3997319382c09241898da4f6cae3b1c8fc74508d616d1a75f7488755dd281 | ['e91f59aefbb44cea98b9f8c4b065551f'] | This is the method I used for doing something similar. I use a global variable to hold the handle of a TextView created in the Activity class. The global is assigned by making a call from the Activity class to the render class.
Code in render class:
private static TextView glbTv1 = null;
public void assignTextviewGlobalHandles(TextView tv1){
glbTv1 = tv1;
}
public void mycallbacktomainactivitymehod(){
if(glbTv1 !=null){
final myMainActivity activity=(myMainActivity) this.context;
activity.runOnUiThread(new Runnable() {
public void run()
{
//glbTv1 is assigned through a TextView varaible created in the Activity class, by making a call into the render class.
glbTv1.setText(String.valueOf(f_jetPos));
}
});
}
}
|
2d75d325789b8617a0b3952732d298f28835306044dd36346e29fb0de59b408d | ['e93989f8252445e7b9004b136b51949f'] | I'm trying to write a script that save me time.
One operation is to unzip files, basic.
I don't want to get the unzip-operation on screen, I mean the verbose messages.
I know about the -q or even the -qq options.
I want the unzip to be done quietly but also to log what has been done in a log file.
I don't know what to do because I'm pretty new to bash-shell and scripting.
My Bash Shell Version : 4.3.11(1)-release.
Is it the best way ?
unzip -o '*.zip' &> log.txt
| b41f699f1316b070aae827fe0a37657c7180abb511b64a4673388ee201941218 | ['e93989f8252445e7b9004b136b51949f'] | Here is my complete script with the tips you gave me, thank you.
it's my 1st, so it's upgradable :-)
thank you again.
#!/bin/bash
clear
printf "Un-ZR v1.0 running w/ Bash Shell v%s\n" "${BASH_VERSION}"
printf "%s\n" "$(pwd | sed "s:$HOME:~:" | sed "s:\(.\)[^/]*/:\1/:g")" &> log.txt
tree &>> log.txt
read -rsp $'\nProcessing in (3s)...\n\n' -t 3
printf "1. UnZIP\n"
unzip -o '*.zip' &>> log.txt
printf "2. UPPER ==> lower\n"
for i in *
do mv "$i" "$(echo "$i" | tr '[:upper:]' '[:lower:]')" &>> log.txt
done
find . -type f -name "*nfo" -print &>> log.txt
find . -type f -name "*diz" -print &>> log.txt
printf "3. UnRAR\n"
/bin/unrar e -r -y "*.r*" . &>> log.txt
printf "4. Delete ZIP n RAR\n"
rm -v ./*.r* &>> log.txt
rm -v ./*.zip &>> log.txt
printf "\n Log available : %s\n" "$(find . -type f -name "log*")"
read -rsp $'\nEnd\n' -t 3
exit
I'm not sure for the /bin/unrar command because I found several unrar on the system... It works though.
|
23a197e20fc4cc384e45c10986c23c7bcf29343e7b3d17807ea223bfa934a80c | ['e942ccc6b5a44904b41953f9bd4ad1d7'] | I have two classes. A class called Cat, that holds the cat names, birth year and weight in kilos. I have a class called Cattery that is an array. I want to input cats from the Cat class into the array. Each cat will have its own name, birth year and weight in Kilos. How do I do this? Thank you.
public class Cat {
private String name;
private int birthYear;
private double weightInKilos;
/**
* default constructor
*/
public Cat() {
}
/**
* @param name
* @param birthYear
* @param weightInKilos
*/
public Cat(String name, int birthYear, double weightInKilos){
this.name = name;
this.birthYear = birthYear;
this.weightInKilos = weightInKilo
}
/**
* @return the name.
*/
public String getName() {
return name;
}
/**
* @return the birthYear.
*/
public int getBirthYear() {
return birthYear;
}
/**
* @return the weightInKilos.
*/
public double getWeightInKilos() {
return weightInKilos;
}
/**
* @param the name variable.
*/
public void setName(String newName) {
name = newName;
}
/**
* @param the birthYear variable.
*/
public void setBirthYear(int newBirthYear) {
birthYear = newBirthYear;
}
/**
* @param the weightInKilos variable.
*/
public void setWeightInKilos(double newWeightInKilos) {
weightInKilos = newWeightInKilos;
}
}
The array class.
import java.util.ArrayList;
public class Cattery {
private ArrayList<Cat> cats;
private String businessName;
/**
* @param Cattery for the Cattery field.
*/
public Cattery() {
cats = new ArrayList<Cat>();
this.businessName = businessName;
}
/**
* Add a cat to the cattery.
* @param catName the cat to be added.
*/
public void addCat(Cat name)
{
Cat.add(getName());
}
/**
* @return the number of cats.
*/
public int getNumberOfCats()
{
return cats.size();
}
}
| aa553ca68e982b79d826e96f5fa812d8c6d39baf7eadfb739d57f0fad13d96e5 | ['e942ccc6b5a44904b41953f9bd4ad1d7'] | I am stuck trying to make a deck shuffling method. I searched for answers on Stack Overflow but have not been able to figure it out.
I want to create a shuffle method. This method will pick two random numbers from the array between 0 and the size of the deck. I then want the two numbers to be passed as parameters to my swap() method. I want to create a loop so that the swap method gets called TIMES_TO_SHUFFLE times. What is the best way to do this?
This is the Deck class.
import java.util.ArrayList;
/**
* Deck of cards.
* @author <PERSON>
* @version 2014.11.19
*/
public class Deck {
private ArrayList<Card> deck;
public static final int TIMES_TO_SHUFFLE = 10;
/**
* Constructor for objects of class Deck
* Creates a new container for Card objects
*/
public Deck() {
deck = new ArrayList<Card>();
}
/**
* Swap two cards that the user chooses.
*/
public void swap(int indexA, int indexB) {
Card temp = deck.get (indexA);
deck.set(indexA, deck.get (indexB));
deck.set(indexB, temp);
}
/**
* Shuffles two cards by passing parameters to the swapCards method
*/
private void shuffle() {
}
/**
* Add a card to the deck.
* @param Card to be added
*/
public void addCard(Card cardToAdd) {
deck.add(cardToAdd);
}
/**
* Take the first card from the deck.
* @return <PERSON> or null
*/
public Card takeCard() {
if(deck.isEmpty()) {
return null;
} else {
// get the top card
return deck.remove(0);
}
}
/**
* Show the contents of the deck.
*/
public void showDeck() {
for(Card eachCard : deck) {
System.out.println(eachCard.getDescription()+
" of " + eachCard.getSuit());
}
}
}
This is the <PERSON> class.
/**
* Card class - a typical playing card.
*
* @author <PERSON>
* @version 2014.11.18
*/
public class <PERSON> {
private String suit;
private int value;
private String description;
/**
* @default constructor
*/
public Card(){
}
/**
* Constructor for objects of class <PERSON>
* @param suit e.g. "Hearts"
* @param value e.g. 10
* @param description e.g. "Ten"
*/
public Card(String description, String suit, int value) {
this.suit = suit;
this.value = value;
this.description = description;
}
/**
* @return the suit
*/
public String getSuit() {
return suit;
}
/**
* @param suit the suit to set
*/
public void setSuit(String suit) {
this.suit = suit;
}
/**
* @return the value
*/
public int getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(int value) {
this.value = value;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description the description to set
*/
public void setDescription(String description) {
this.description = description;
}
}
|
a09a27dd9ba1a05fc51cd97a57195052288675fa32b4a353cae6ddf6c060176c | ['e9436b0667f74b2b979ff53970cbd4b2'] | I have a data set with n samples d features represented by a n*d matrix. The corresponding label is a n*1 vector. How can I compute each intraclass standard deviation without loops in matlab?
For example:
Samples
5 1 1 1 4
5 2 5 3 1
1 3 5 5 5
5 5 3 4 5
4 5 5 5 4
Label:
2
1
1
2
2
How can I compute class 1 and class 2's standard deviation?
| bbb68b1b9d919ab9127b1a068a0c8bb0ae7991d25030bb17ee35516dea015d9a | ['e9436b0667f74b2b979ff53970cbd4b2'] | I am learning python. Today I meet with a odd problem.
from urllib import urlopen
url='http://www.google.com'
f=urlopen(url).read()
print f
It is a sample script ,it can run if it in C partition however in D partition
it has AttributeError:
Traceback (most recent call last):
File "D:\urlopen.py", line 1, in <module>
from urllib import urlopen
File "D:\urllib.py", line 7, in <module>
nettext=urllib.urlopen(strurl).read()
AttributeError: 'module' object has no attribute 'urlopen'
I installed python2.7 and python3.1 in win7,and I run the script in python2.7's shell.
|
03d89e5d291eac19b2e6f66ca097e9546305cc4b94eec833ba2c40728f1fd507 | ['e946d05413844d6d87ec154be1169ed3'] | I'm not really sure what you are trying to do with the headers but I'd suggest you do some reading on CORS. This is a pretty good resource. If you wanted to limit who can access your endpoint you could set Access-Control-Allow-Origin: http://someurl.stuff.com
$.ajax({
url: "http://someurl.stuff.com",
type: 'GET',
dataType: "json",
success: function (data) {
console.log("Success")
console.log(data);
},
error: function(xhr){
console.log("failure")
console.log("An error occured: " + xhr.status + " " + xhr.statusText)
}
})
| 9324e68857a877a15e305e4b71cd99e9682e6601d3de57b39131cb0bcb829668 | ['e946d05413844d6d87ec154be1169ed3'] | There is no need to use a package for this, just set up a middleware like so
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
As previously mentioned, to limit access to a particular domain change the * to https://whateveryourdomainis.com. If you want allow access to a number of domains then do as <PERSON> has outlined
|
962312eab0c98523d8cf13f93c8eebf745faa89acb278e2576ee91b2b7221707 | ['e9504b8b19934bfab05a1923d1df2528'] | If I have a folder full of similar files, is there a technique to open all of its files with a particular app? For example, I would like to right-click on a folder and Open With a selected app.
I know I can do this by entering into the folder and selecting some or all of its files. I just wondered whether there is a way to do this on the folder itself.
| cad2454d1c0dccfcde4dfaac42bb2ee90b033e51dfb13d6b85958b5d3726696b | ['e9504b8b19934bfab05a1923d1df2528'] | I see a technical book on the iBooks store which looks interesting. The description tells me everything except:
What format (PDF, ePub etc) is supplied?
Does the book have DRM?
I don’t know whether the answer is always the same, but how can I find out about the book on the store?
|
d2de6f8d466c272b429f8ff324eb2b7cf533b25cb0a4ed5bb3a149b5cef05922 | ['e958498398d0414ba999802e90a1ae21'] | I have problem with custom html helper. I try to build a helper, using TagBuilder but I'm unable to close it.
Here is my code:
public static HtmlString CustomHelper(this HtmlHelper htmlHelper,
string id)
{
var contentDiv = new TagBuilder("div");
contentDiv.MergeAttribute("style", "display:inline-block");
var input = new TagBuilder("input");
input.AddCssClass("forDD");
input.MergeAttribute("type", "hidden");
input.MergeAttribute("id", id);
input.MergeAttribute("value", "Cat");
contentDiv.InnerHtml += input;
return new HtmlString(contentDiv.ToString(TagRenderMode.EndTag));
}
But the result of it looks like:
Something is wrong but I can't find out what, I'm missing it. Even closing input tag is wrong. I have checked version of dlls and have tried with MvcHtmlString ect. Also the TagRenderMode doesn't work at all.
Thanks for the help.
Best regards.
| a0222ee809592b579df3acbe0c8ae0ce143d2bd7354e2c5d9484899bb6d6d2c3 | ['e958498398d0414ba999802e90a1ae21'] | I have a class Users:
class User
{
public string Name { get; set; }
public Address Address { get; set; }
public DateTime Birthday { get; set; }
}
Then I have a list of users like List<User> users.
And I meet with the problem which sounds "How to order list by Name length string property?
I've tried something like this:
users.OrderBy(user=>user.Name.Length);
and unfortunately it didn't work.
Thanks for the reply and best regards.
|
140bea390f34aa882b1b1a38fe14ace888a41f08001f7839cd5352f4075cd72a | ['e95e5e9aaddb4917a51f410d853d76ad'] | Gallactic Jello is on the right path. The part he left out is overcoming the problem of the generic library knowing about classes in the center library, which I have further addressed. I've created a sample solution with three projects, the full contents of which I'll spare you. Here is the gist.
Class Library: Generic lib
Contains a Message_Handler, his own IMessage_Creator, definitions of the interfaces, and an IMessage type of his own.
Class Library: Center Lib
Contains an IMessage_Creator, and his own IMessage type.
Application: Application
has a SVM (static void Main()) containing the following lines of code:
Generic_lib.IMessage msg = Generic_lib.Message_Handler.get_message(2); //a Center Message
if (msg is Center_lib.Center_Message)
{
System.Console.WriteLine("got center message");
}
You will be amazed how important the if statement is!!! I'll explain later
Here's the code in the Type Initializer for Generic_lib.Message_Handler:
static Message_Handler()
{
//here, do the registration.
int registered = 0;
System.Reflection.Assembly[] assemblies = System.AppDomain.CurrentDomain.GetAssemblies();
foreach (System.Reflection.Assembly asm in assemblies)
{
System.Type[] types = asm.GetTypes();
foreach (System.Type t in types)
{
System.Type[] interfaces = t.GetInterfaces();
foreach (System.Type i in interfaces)
{
if (i == typeof(IMessage_Creator))
{
System.Reflection.ConstructorInfo[] constructors = t.GetConstructors();
foreach (System.Reflection.ConstructorInfo ctor in constructors)
{
if (ctor.GetParameters().Length == 0)
{
Add_Creator(ctor.Invoke(new object[0]) as IMessage_Creator);
registered++;
}
}
}
}
}
}
System.Diagnostics.Debug.WriteLine("registered " + registered.ToString() + " message creators.");
}
Horrific, isn't it? First, we get all the assemblies in the current domain, and here's where the if statement comes in. If there was no reference to the 'Center__lib' anywhere in the program, the array of Assemblies won't contain Center_lib. You need to be sure that your reference to it is good. Creating a method that is never called that references it is not enough, a using statement is not good enough,
if (msg is Center_lib.Center_Message) ;
is not enough. It has to be a reference that can't be optimized away. The above are all optimized away (even in Debug mode, specifying `don't optimize.'
I hope someone can come up with an even more elegant solution, but this will have to do for now.
<PERSON>
| 33dafa1bf46ccf155df754a9a373705d120e0e6b4e9e0e66831ec5af04201ff5 | ['e95e5e9aaddb4917a51f410d853d76ad'] | I'm debugging some code that uses Map<Integer,...>, but I'm having great difficulty finding the values associated with various Integers! Here's a minimum working example:
java code (saved to .\src):
import java.util.Map;
import java.util.HashMap;
public class Hello {
public static void main(String[] args) throws java.io.IOException {
Map<Integer,String> mymap = new HashMap<Integer,String>(2);
mymap.put(new Integer(5), "five");
mymap.put(6, "six");
}
}
Terminal 1 (powershell):
javac -g $(ls . *.java -r -name)
java -cp src -Xdebug '-Xrunjdwp:transport=dt_shmem,server=y,suspend=y,address=hey' Hello
Terminal 2 (powershell):
jdb -attach hey
...
VM Started: No frames on the current call stack
main[1] stop at Hello:10
Deferring breakpoint Hello:10.
It will be set after the class is loaded.
main[1] cont
> Set deferred breakpoint Hello:10
Breakpoint hit: "thread=main", Hello.main(), line=10 bci=40
main[1] dump mymap.get(5)
com.sun.jdi.InvalidTypeException: Can't assign primitive value to object
mymap.get(5) = null
main[1] dump mymap.get(new Integer(5))
com.sun.tools.example.debug.expr.ParseException: No class named: Integer
mymap.get(new Integer(5)) = null
main[1]
How should I go about looking up a value from a Map<Integer,?>?
|
2024e631dd495a566641397a936e215823df663069d556b8927bc618e954be86 | ['e964b164c6f94aa9ae89eb03f48f964e'] | I would like to create tokens where its price is pegged to the price of Ethereum (i.e. Ether price goes up, my token price goes up). Regardless of number tokens been sold or changed hands.Is it possible? Any examples out there for such scenario?
Appreciate all your help. Thank you so much.
| b12c9deeb748936df5dc977ddd299ed0b5464c3ebf97cc979e1827021797a33f | ['e964b164c6f94aa9ae89eb03f48f964e'] | I asked a friend how they were doing and they replied "元気でやってるよ". What is the meaning of でやってる? Is this some variation on である (to be) or is it a form of やる (to do)? If it is the latter, why does it use 元気"で" and not 元気"に"?
|
50e09ca78f50f45e8d0252b7720913861f8cadc87ea3ba0c238ba868319beab8 | ['e96d24b80e744391895ba33606b54c70'] | У меня есть строка
let str='(`id`=3) and (`filter`=\'test\' or (`filter`=\'1\' and `name`=\'2\'))'
Мне нужно чтобы строка превратилась в такой массив
let arr=[['id','=', '3'], 'and', [['filter','=', 'test'],
'or',
[['filter','=', '1'],
'and',
['name', '=', 'i']]]]
Я сделал это
let str = "((`id`=3) and (`filter`='te\\\'st' or (`filter`='1' and `name`='2')))";
let expression = [];
let i = 0;
let level = 0;
let result = matches(str, /'(\\.|[^'])*'/ig, i, 't');
let text = result.text;
let phrase = parseSQL(result.result, level, expression);
console.log({phrase, text, expression});
console.log(getArray(expression));
function parseSQL(str, level, expression) {
let j = 0;
let result = matches(str, /\([^()]+\)/gi, j, `e${level}_`);
let phrase = result.result;
expression.push(result.text);
if (result.result.match(/\(/)) {
phrase = parseSQL(result.result, level + 1, expression);
}
return phrase;
}
function matches(str, regex, i, letter) {
let result = str.replace(regex, function () {
return `$${letter}${i++}`;
});
let text = str.match(regex);
return {result, text};
}
У меня есть массив в котором есть ключи с уровнем, по которым я смогу собрать нужный вложенный массив, только не могу придумать как это сделать
| e0050b8bb90373f1d46130ceb01e2086ee0a17e72544fe03de477c8464aff27c | ['e96d24b80e744391895ba33606b54c70'] | Now I have apache configuration which works only with localhost domain (http://localhost/).
Alias /media/ "/ścieżka/do/instalacji/django/contrib/admin/media/"
Alias /site_media/ "/ścieżka/do/plikow/site_media/"
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
PythonPath "['/thomas/django_projects/project'] + sys.path"
PythonDebug On
</Location>
<Location "/site_media">
SetHandler none
</Location>
How can I make it working for some subdomains like pl.localhost or uk.localhost?
This subdomains should display the same page what domain (localhost).
Second question: It is possible change default localhost address (http://localhost/) to (http://localhost.com/) or (http://www.localhost.com/) or something else?
|
61b0b87a556d58a618cc49702c5db51fe02e60256bcdf6d57b7012f50cbaf445 | ['e979eb3261c54c28b6d811866d220567'] | I have an EC2 WindowsServer2016 image with a scala project on it. I want it to start when I spin up an instance without me having to log in or do anything. I have a .bat script with the following:
git pull
sbt run
In the TaskScheduler I created a task. Here is the XML.
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2017-07-19T10:34:17.5913961</Date>
<Author>EC2AMAZ-KLIVN0Q\Administrator</Author>
<URI>\StartServer</URI>
</RegistrationInfo>
<Triggers>
<BootTrigger>
<Enabled>true</Enabled>
</BootTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-5-21-1707681336-2717460810-1492664229-500</UserId>
<LogonType>Password</LogonType>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
<UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>C:\Users\Administrator\cbf-render-server\run.bat</Command>
<WorkingDirectory>C:\Users\Administrator\cbf-render-server\</WorkingDirectory>
</Exec>
</Actions>
</Task>
PROBLEM: the server starts whenever I RDP into the machine. If I don't RDP into the machine it never seems to start. (I test whether it has started by curling the health endpoint).
I'm new to WindowsServer (UNIX background) could someone please tell me what I might be doing wrong?
Thanks
| 2cd24d038df9f92225097555ac46b2c73d55981173532b9110427ef5d6c0a56a | ['e979eb3261c54c28b6d811866d220567'] | yea, i can manual start, and all be ok if I do it. process created and log writing. if I need stop him, I use kill command. But if I start from sh (example: sudo su root; sh /etc/init.d/odoo-test start) pid file is creating, but odoo don't work, and i can't stop from sh /etc/init.d/odoo-test stop |
39aeefdc2d7067e839b7365947bb3a3c2b5829aa092893eaf9fde4bedd0aaee8 | ['e97dd461f91840c4815dba64db583f6e'] | <PERSON> comment seems to be right, at least at this point in time.
I don't think the Python kindless ancestor query is supported in Go.
For a moment there I thought you could use the ancestor key's Kind()
method, then I had some more coffee and came to my senses.
| b1c1bbfe8ae2961310fb11959573b591cd868d2a18c4138a961ef14bb79cc8e2 | ['e97dd461f91840c4815dba64db583f6e'] | Currently im using this command in terminal to compress a single image with imagemagick:
./convert_with_logging photo.jpg -quality 50% photo2.jpg
convert_with_logging is a script that contains:
INPUT_FILENAME="$1"
OUTPUT_FILENAME="$4"
ORIGINAL_SIZE=$(wc -c "${INPUT_FILENAME}" | cut -d ' ' -f1)
convert "$@"
COMPRESSED_SIZE=$(wc -c "${OUTPUT_FILENAME}" | cut -d ' ' -f1)
echo "${OUTPUT_FILENAME} | saved size: $(expr $ORIGINAL_SIZE - $COMPRESSED_SIZE)"
Note: this script converts and it also log the compressed size (ex: imageA.jpg | saved size: 1994825
)
Now currently im using this command to compress multiple images (that are jpg and jpeg):
for PHOTO in /home/dvs/Desktop/proj1/src/images/*.{jpeg,jpg}
do
BASE=`basename $PHOTO`
./convert_with_logging "$PHOTO" -quality 40% "/home/dvs/Desktop/proj1/src/compressed/$BASE"
done;
Now how can i convert all this last command in order to type "./convert_multi_with_logging" and get the same result?
I think that we need to add something like this to the script:
inpath="/home/dvs/Desktop/proj1/src/images/"
outpath="/home/dvs/Desktop/proj1/src/compressed/"
|
3b806f1a88a0399c4a4dfad62529fcaba00fc1b702dd239f7a622b73748b11de | ['e996b692972d4dac9404dff6cf189ecb'] | Lets say I have a postgres table named Employee with the following columns:
ID
FirstName
LastName
Employment
Date
Manager
Department
I am interested in having a REST endpoint such that /employee/{ID} will return all information for that particular employee in JSON format, but if I specify /employee/{ID}/FirstName then it'd return particular employee's first name only in JSON format, /employee/{ID}/LastName would return the employee's last name in JSON format, and so on. Is there a good way to implement this instead of implementing an endpoint for accessing each column? Thanks.
| 16e9bfcb9b917a54201dc0e11da7851a6aa0b8e7b06706740ed62c1f67b81934 | ['e996b692972d4dac9404dff6cf189ecb'] | I am trying to do some simple updating of a string in a function, I got the following sample to work:
void change(char* buffer) {
buffer[0] = 'b';
}
void main() {
char buffer[20] = "abc def ghi j\0";
printf("before: .%s., %p\n", buffer, buffer);
change(buffer);
printf("after: .%s.\n", buffer);
}
But if I use char* for buffer instead of char[], I get an error in the function. So the following example doesn't work:
void compact(char* buffer) {
buffer[0] = 'b';
}
void main() {
char* buffer="abc def ghi\0";
printf("before: .%s., %p\n", buffer, buffer);
change(buffer);
printf("after: .%s.\n", buffer);
}
Any suggestions on what I am doing wrong? Thanks.
Don
|
5084745ca821bad8f19e49ab7ac6f612ef267ea28cb4be423a75b93529b08103 | ['e9a1895d189c46aaa7c4fb645d3ce4e1'] | Is there a way to exclude an entire directory from git if a certain file is present in there?
For instance, I have a lot of test cases which create new directories with an _SUCCESS file. I want to exclude any directory that has a _SUCCESS file. I do not care about what other files are in there.
| f279a4ac6e596858b0dc603c808088d0ffba12db05c1143588f7cd8676ef1045 | ['e9a1895d189c46aaa7c4fb645d3ce4e1'] | The schema in your LOAD statement is incorrect. info is a name and {"Id":53556,"State":"Ohio"} is its value. This value is an object which is again an unordered set of name/value pairs i.e. "Id":53556 and "State":"Ohio"
Try this
read =
LOAD 'test.dat'
USING JsonLoader('
info:(
id : CHARARRAY
, state : <PERSON> )
, time : CHARARRAY
');
proj =
FOREACH read
GENERATE
FLATTEN(info) AS (
id
, state )
, time
;
proj2 =
FOREACH proj
GENERATE
state
, time
;
dump proj2;
Output
(Ohio,139140)
(Calif,1391407471477)
|
de5fad097abe92dd7cb2fb3efdd4f951d92dadb317c1914ea192cd9272e9b355 | ['e9b40449001a47d79f400423c14c7fb1'] | This is an addon to @FaneDuru's solution that implements a dialogbox showing the printer list, highlighting the currently active printer and allowing you to select any other printer. It also encompasses the fix for the problem with the "Send to OneNote 2016" printer problem. The code is for running the dialog box shown below:
To run the dialogbox simply add: ufSelectPrinter.Show to your VBA code.
Note: You'll have to create the dialog box using the labels shown in the code.
Option Explicit
Dim Printers() As String
Private Sub UserForm_Initialize()
Dim iSelPtr As Integer
Dim lCntr As Long
Dim zCurPtr As String
zCurPtr = Application.ActivePrinter
Printers = GetPrinterFullNames()
For lCntr = LBound(Printers) To UBound(Printers)
'*** Fix for: "Send to OneNote 2016" printer that
'*** that prints to nul: port which is dropped
'*** by GetPrinterFullNames() routine.
If InStr(Printers(lCntr), ":") = 0 Then
Printers(lCntr) = Printers(lCntr) & "nul:"
End If
'*** END of Fix ***
'*** Find current printer in the list and adjust the
'*** index for the zero based listbox.
If Printers(lCntr) = zCurPtr Then iSelPtr = lCntr - 1
Next lCntr
'*** Populate the List Box ***
Me.lboxSelectPrinter.List = Printers()
'*** Highlight the current Active Printer ***
Me.lboxSelectPrinter.Selected(iSelPtr) = True
End Sub
Private Sub CBCancel_Click()
Unload Me
End Sub
Private Sub CBOk_Click()
Dim iSelected As Integer
iSelected = Me.lboxSelectPrinter.ListIndex + 1 '***Zero Based***
' Debug.Print Printers(iSelected)
Application.ActivePrinter = Printers(iSelected)
Unload Me
End Sub
HTH
| 66c6b50148551f0b28c0f35746dfb9dc53b3503db1859c16d55e67afd20a074e | ['e9b40449001a47d79f400423c14c7fb1'] | <PERSON>,
<PERSON> posted his answer while I was working on it. While it will work, if I'm not mistaken, and that may well be the case, the items will be copied in reverse order to the new destination sheet. If order is important you may what to try using a Do/Loop as follows:
Option Explicit
Sub Complete()
Dim lRow As Long
Dim shtWS As Worksheet
Dim shtDest As Worksheet
Dim lLastRowSDes As Long
'*** Don't use ActiveSheet rather specify the name
'*** If called from more than one sheet pass as parameter.
Set shtWS = WorkSheets("your sheet name here")
set shtDst = Worksheets("5.Complete & Verified")
lLastRowSDes = ActiveSheet.Cells.Find("*", _
searchorder:=xlByRows, _
searchdirection:=xlPrevious).Row + 1
lRow = 2 'Set Starting Row
Do
If shtWS.Cells(lRow, "R") = "Complete & Verified" Then
shtWS.Range("B" & lRow & ":T" & lRow).Copy
shtDst.Range("B" & lLastRowSDes).Paste
shtWS.Rows(lRow).Delete
'*** Note we don't increment counter as next row moves up to current lRow position!
shtDst.Cells(lLastRowSDes, 1) = shtWS.Name
lLastRowSDes = lLastRowSDes + 1
Else
lRow = lRow + 1 'Increment Row Counter
End If
Loop Until (shtWS.Cells(lRow,"B").Value = "")
You'll notice I used Copy/Paste as I've never seen the syntax of assigning one range to another like that, very neat! So you could just replace the copy/paste lines with that one.
FYI: code not tested!
HTH
|
7d2c8fc14e78e04280c04159a9d47bfba015056eda2cc4fb00ba83b52cb3ba6f | ['e9b9e06ea191408ea503633ecba55b66'] | I'm having an issue the typescript generics:
function isString(a: any): a is string {
return typeof a === 'string'
}
function concat<T extends string | number>(a: T, b: T): T {
if (isString(a) && isString(b)) {
return a.concat(b)
}
return a + b
}
Playground url: https://www.typescriptlang.org/play/index.html#src=function%20isString(a%3A%20any)%3A%20a%20is%20string%20%7B%0D%0A%20%20%20%20return%20typeof%20a%20%3D%3D%3D%20'string'%0D%0A%7D%0D%0A%0D%0Afunction%20concat%3CT%20extends%20string%20%7C%20number%3E(a%3A%20T%2C%20b%3A%20T)%3A%20T%20%7B%0D%0A%20%20%20%20if%20(isString(a)%20%26%26%20isString(b))%20%7B%0D%0A%20%20%20%20%20%20%20%20return%20a.concat(b)%0D%0A%20%20%20%20%7D%0D%0A%20%20%20%20return%20a%20%2B%20b%0D%0A%7D%0D%0A
The typing seems appropriate but I have some errors. There seems to be some confusions around typescript generics but none of the answers I found helped me with that basic use case.
| 65a739c57dea3dd41b746512d1ecd1e2c8c07a139d9b6424f08740776ae14a1e | ['e9b9e06ea191408ea503633ecba55b66'] | So I'm having some real troubles trying to design a responsive website. The problem comes from the fact that I am using the vh unit, that sets some of my div to 100% of the viewport height.
While this works perfectly fine on desktop, my issue is that the viewport on mobile actually changes :
As you scroll down the navigation bar (from chrome for example) disappears, making the viewport taller. When this happens, the divs that are based on the vh unit re-adapt and makes everything slide a little (which is really not good-looking when you're scrolling down).
If you want to go back on something you missed, scrolling up makes the navigation bar appear again, and everything slides again the other way.
So basically, if the user slides up and down on my website, this issue will make it's experience way worse than it should.
Is there any solution that allows me to set my divtoo full viewport dimensions without allowing things to resize / adapt to the things that resize ?
|
f0ce19d423884ba6be144e6ec6ebb67e83b3b8b7d1bc913c3bf1916c5732fbb8 | ['e9c4d67b4aca42d0b4186ab9fc1c2c34'] | OUT PUT IS LIKE THIS :status vsftpd
vsftpd stop/waiting AND FOR
start vsftpd
start: Rejected send message, 1 matched rules; type="method_call", sender=":1.70" (uid=1000 pid=3522 comm="start vsftpd ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init") | 27d692a274a034ab25ef86c8b16d31fb2b21c952a2b3dc7b777386bc43745572 | ['e9c4d67b4aca42d0b4186ab9fc1c2c34'] | <PERSON> want to remove all the images from a document in LibreOffice Writer. My document contains ~ 350 images. Is there a way to delete them en masse rather than one by one? I tried unchecking Tools > Options > LibreOffice Writer > View > Display > "Graphics and objects". But the place-holders are still visible.
Edit: I know about saving the page as a plain text file, But I need formatting in my document.
|
994949add39415f211ee3fa15bdbcd975a61adc8961b66d724e9b4cef15f357d | ['e9c5d27761414f1eb81c85ed22e5cae9'] | A good practice is to use the CBV
class UserCreateView(CreateView):
def get_form_class(self):
class _Form(forms.ModelForm):
passwd = forms.CharField(widget=forms.PasswordInput(), max_length=100, help_text="Password: ")
rpasswd = forms.CharField(widget=forms.PasswordInput(), max_length=100, help_text="Re-Type Password: ")
...
def clean(self):
...
class Meta:
fields = ('username', 'email', ...)
return _Form
def form_valid(self, form):
# additional logic
| ef5d524915e8ec1652f45ce9a131a406f2bc643e27e0a2cb3e4b42a42b2edafa | ['e9c5d27761414f1eb81c85ed22e5cae9'] | views.py
class SearchView(FormView):
template_name = 'apps/frontend/search_view.j2'
def get_form_class(self):
class _Form(forms.Form):
search = forms.CharField(label='search')
return _Form
def form_valid(self, form):
return self.render_to_response(self.get_context_data(form=form))
html
<h1>current:{{ form.search.value()|default('') }} - jinja2 format</h1>
<form action="." method="post">
{% csrf_token %}
{{ form }}
<button type="submit">submit</button>
</form>
|
db1e2327d45cec6f0547a5df653ef7172f9b0c70059274d8ee747f464be71bb4 | ['e9c975b8b6534b52807013b8bf62af1c'] | I'm following a tutorial for Devise+Omniauth+Rails 4 with multiple providers. My code is very close to the examples at the sourcery tutorial except that I've left off the confirmable module and changed linkedin to google_oauth2.
Everything is working fine until I get to the callback and then rails raises this error:
NameError - undefined local variable or method `provider' for #<OmniauthCallbacksController:0x007fa8312a5298>:
(eval):7:in `twitter'
Here's my OmniauthCallbacksController (nearly identical to the link above):
class OmniauthCallbacksController < Devise<IP_ADDRESS>OmniauthCallbacksController
def self.provides_callback_for(provider)
class_eval %Q{
def #{provider}
@user = User.find_for_oauth(env["omniauth.auth"], current_user)
if @user.persisted?
sign_in_and_redirect @user, event: :authentication
set_flash_message(:notice, :success, kind: provider.capitalize) if is_navigational_format?
else
session["devise.#{provider}_data"] = env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
}
end
[:twitter, :facebook, :google_oauth2].each do |provider|
self.provides_callback_for provider
end
end
| b6f36a7d729dee466ea8863a9eafd4185ef1c6cd979993397c0abeba7f6b91ea | ['e9c975b8b6534b52807013b8bf62af1c'] | Use the select2 createSearchChoice function to allow the user to input their own option. Then use the change event on select2 to listen for any new search choices and launch a mini-form or unhide a link on the page to add additional details if a custom choice is selected.
|
435818f14ab505f69c5df589ff4bc52c841f7097a9fe585e5a4d02b0d38ddf7b | ['e9d058d5fded4db6947c3fcd8ce049cb'] | We have a View in SQL Server that constantly evolving.
We want to show it in a report as it is (If we add/remove a field in the View, we don't have to modify the report and add/remove manuelly the field).
A sort of a table/matrix that is refreshing by itself.
Thank you by advance for your help.
| 86cdf32a5a88b6729f28ac402d1c7d5de9891ea450b99f83f9eb7f63c2cf66ad | ['e9d058d5fded4db6947c3fcd8ce049cb'] | I'm trying to write a script that will get the value of a node in multiple XML files.
Here is the XML structure :
<Report>
<ReportSections>
<ReportSection>
<Body>
<ReportItems>
<Textbox Name="lbReportName">
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Activity Report</Value>
</TextRun>
</TextRuns>
</Paragraph>
</Paragraphs>
</Textbox>
</ReportItems>
</Body>
</ReportSection>
</ReportSections>
</Report>
I use this script to search through the XML :
Select-XML -Path "N:\TEMP\XML\0.xml" –Xpath "//*[@Name='lbReportName']"
(Because the structure is not the same above the name "lbReportName").
Now, how can I get the value "Activity Report" ?
(After the name "lbReportName", the structure is the same for all XML files)
|
68258602ff06c195327e004d3ef174a352979269c387697cc4896a81464744fb | ['e9d20a3b81d5447baff7530b1e883702'] | Here I have a code that create a sidebar:
var side_bar_html = "<a href='javascript:google.maps.event.trigger(gmarkers[" + parseInt(gmarkers.length - 1) + "],\"click\");'>" + place.name + "</a><br>" + '<div class="raty" />' + "</br>";
$(side_bar_html).appendTo('#side_bar').filter('.raty').raty({
score : place.rating,
path : 'http://wbotelhos.com/raty/lib/img'
})
How I can create a function from this code to create a sidebar with function ...
So something like that:
function Create_a_sidebar_and_put_it_into_ID#sidebar () {
//for every marker to return html string
return "<div class='element'>"+place.name+"</br>"+place.rating+"</div>" + etc...
Becouse I have a problem with creating html, I dont know what to append where and I dont have contol over that
Is it possible?
| 608400a8a6b6b8f6eb300fb13f82b7bcec96ce01bc50e58d764b1d11f5b7676f | ['e9d20a3b81d5447baff7530b1e883702'] | Here I have a function calculateDistance which must return me a distance between two places and time so I write:
function calculateDistances(start,stop) {
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: [start],
destinations: [stop],
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC,
avoidHighways: false,
avoidTolls: false
}, callback);
}
function callback(response, status) {
if (status != google.maps.DistanceMatrixStatus.OK) {
alert('Error was: ' + status);
} else {
var origins = response.originAddresses;
var destinations = response.destinationAddresses;
for (var i = 0; i < origins.length; i++) {
var results = response.rows[i].elements;
for (var j = 0; j < results.length; j++) {
var xxx= "";
xxx += origins[i] + ' to ' + destinations[j]
+ ': ' + results[j].distance.text + ' in '
+ results[j].duration.text + '<br>';
return xxx;
}
}
}
}
after that I write a code to implement this function into my js code:
//Start function for calculate distance
var start = document.getElementById("from").value;
var stop = place.formatted_address;
contentStr += '<p>'+ calculateDistances(start,stop); + '</p>';
//I open rendered HTML in jquery dialog when user click on marker
$(contentStr).dialog({
modal:true
});
I just get as HTML: undefined and in console: Uncaught TypeError: Cannot read property '__e3_' of null
How I can solve this problem?
FULL CODE: http://jsbin.com/EVEWOta/96/edit
|
292f491d96955e4174f52fa5be037ee32de019a67e9cd272787b6729de22ce36 | ['e9d6e84b0c314dadbb93b1e266d7b230'] | I have a class:
class Foo{
var x:Long = 10
set(value) {if( value < 0 ) throw IllegalArgumentException("error"); field=value}
}
Is it possible to validate these values in a more elegant way? For example - I want something like this:
class Foo( @Positive var x: Long) {
}
Is it possible? I want it to be lightweight - no reflections, just check on settler. Any suggestions?
| 50f5bbee13e8802f4ce0057c004184ca38f8ee5a7811a37c1d0c32f8e16affdc | ['e9d6e84b0c314dadbb93b1e266d7b230'] | I have an entity with named query.
@Entity(name = "MyEntity")
@Table(name = "mytable")
//@ReadOnly
@NamedQueries({
@NamedQuery(
name = "exampleFind",
query = "[..]",
hints = {@QueryHint(name= QueryHints.QUERY_RESULTS_CACHE, value= "TRUE")})
})
@Cacheable
@Cache(type = CacheType.FULL)
public class MyEntity {
When I annotate this class with @ReadOnly then this query does not hit the database (uses results cache only) but when I remove @ReadOnly annotation it always performs SQL on database.
How to enable this cache without @ReadOnly? Are there any limitations on results cache?
I use EclipseLink 2.4.1
|
37aed01c3b1da329cd686a4028a63ef87299fcae55d1ec80a7f4520e0de61f6b | ['e9d766734ba54aabb1cba075d1bc6f1d'] | To Add a label to your gmail in other email accounts you own
Open chrome
Invoke gmail
This will bring you to mobile browser
Tap three dots in corner
Select go incognito
Invoke gmail again
Sign in
Clock 3 straight lines (top left)
Scroll down and select desktop
Add label as you would on computer
| ca2820d52723e2d8ceb3c725aa3abcbab68c40c8eb0ba3316d9724ff25ac88f8 | ['e9d766734ba54aabb1cba075d1bc6f1d'] | To Add a label to your gmail in other email accounts you own
Open chrome Invoke gmail This will bring you to mobile browser Tap three dots in corner Select go incognito Invoke gmail again Sign in Clock 3 straight lines (top left) Scroll down and select desktop Add label as you would on computer
|
a925cba9f1e6cec500daa44958687cd5a04049e1120dbc215f524f3e6c55d813 | ['e9de581795df40ba89cdb4c0fa2f83cc'] | I'm looking for how to quickly find where a class is instantiated in Eclipse. I know that you can use Search and look for new myClassName( in *java files. I'm looking for an option where right click somewhere in the class definition to find where it is instantiated in the project or a keyboard shortcut of some type.
| 46ad6bde143e07115a3398c9aab9783e34f2c6e46a7fcc0d950a0ada15957888 | ['e9de581795df40ba89cdb4c0fa2f83cc'] | I've looked through documentation that says the oplog is a stored collection on the local db. When I attempt to show collections after use local, I receive the error "can't use 'local' database through mongos. Error code: 13644. This seems to be related to having sharding. I am attempting to look at the oplog to see what exactly it says when I insert a specific document.
|
690912f68ca83cd051798a10c8f8e99506e58d00122ebbb429d180b7e42e9d77 | ['e9deb96d7c204c909370dfd5cad703dc'] | I have a view controller within my app that I use for debugging purposes to display some of the internals of the app (only for local xcode builds, the app store version doesn't have this controller).
In this controller, I have a label which I want to reflect the state of an internal component (specifically, I want it to display whether that component is enabled or disabled).
My questions:
#1: Is it expensive to set the .attributedText property of a UILabel to the same value as it was before, or should I cache the old value and only set the property when it changes?
#2: What about the .text (non-attributed) property?
I'm currently using the following code:
// Schedule timer to update the control panel. (This is debug-only, so not worth
// the complexity of making this event-based)
Timer.scheduledTimer(withTimeInterval: 0.5,
repeats: true) { [weak self] timer in
DispatchQueue.main.async {
// Stop timer if we've been dealloced or are no longer being presented
guard let strongSelf = self,
strongSelf.isBeingPresented else
{
timer.invalidate()
return
}
// "Something Enabled / Disabled" label
let somethingIsEnabled = strongSelf.someDepenency.isEnabled
let somethingEnabledString = NSMutableAttributedString(string: "Something ")
somethingEnabledString.append(NSAttributedString(string: isEnabled ? "Enabled" : "Disabled",
attributes: isEnabled ? nil : [NSForegroundColorAttributeName: UIColor(xtHardcodedHexValue: "0xCD0408")]))
strongSelf.somethingEnabledLabel?.attributedText = somethingEnabledString
}
}
| 8ab9b875fb65c6609d87dea83d3e7b446645ff20debbb4f314964f8f9e3ab7ef | ['e9deb96d7c204c909370dfd5cad703dc'] | I'm trying to set up a typescript-based express app workflow using Visual Studio Code & gulp.
Heres my project structure:
src/ <-- souce files
Start.ts
Server.ts
models/
Contact.ts
Organization.ts
bin/ <-- compiled output
Start.js
Start.js.map
...
tsconfig.json
gulpfile.json
package.json
.vscode/
launch.json
Performing the following sequence of commands, I can compile & launch my app in the integrated terminal:
> tsc
> node --debug-brk ./bin/Start.js
At this point, I can successfully attach to my app using the default "attach to process" command (and it even hits breakpoints in the typescript files correctly, yeyy!):
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"address": "localhost",
"port": 5858
}
However, launching with F5 fails every time. There is no output on the Debug Console, and in a few seconds I get an error banner at the top saying Cannot connect to runtime via 'legacy' protocol; consider using 'inspector' protocol (timeout after 10000 ms).
Here's my launch configuration (in launch.json):
{
"type": "node",
"request": "launch",
"name": "Launch Program",
// Using compiled .js file. vscode should use the sourcemap to correlate
// with breakpoints in the source file
"program": "${workspaceRoot}/bin/Start.js",
"outFiles": [ "${workspaceRoot}/bin/**/*.js" ]
}
I tried opening the debug console. Every time I save the launch.json file, it gives me the following error: Cannot read property '_runner' of undefined: TypeError: Cannot read property '_runner' of undefined in shell.ts:426
Googling the error, I came across this bug
What does this bug mean? Is there any workaround for it? What oh what should I do???
|
f415d8b1b997133f5151812fe240db0a5d10402bacff9ca6c3a084c03723017d | ['ea03ba0406794175b943105f47f386c3'] | I'm following the MYSQL Essential Training on Lynda .when trying to Upload the Exercise Files on SQL for the "album-mysql"; I received an error on my phpmyadmin. I have following the instructions by selecting the UTF-8 from the character set of file.Error is showing below
SELECT MAX(version) FROM `phpmyadmin`.`pma_tracking` WHERE `db_name` = 'album' AND `table_name` = 'album' AND FIND_IN_SET('INSERT',tracking) > 0
MySQL said: Documentation
#1100 - Table 'pma_tracking' was not locked with LOCK TABLES
| 69dd2cfd14821a2403abbda5988f6dd4a41aaf9cfb7607f87de1f17e91481e4e | ['ea03ba0406794175b943105f47f386c3'] | I have already installed Python 3.1.2 on my window 7(64bit) .However when I checked if its successfully installed using this command : python --versionI still got an error as "python" is not recognized..". Then I using the command setx PATH "C:\Python 31", error message shown setx is not recognized.."
I have checked that Python 31 was shown under my C drive and i have already open the PYTHON GUI window
Please i need help on where i get this wrong
|
2327053593cd70188082b905d2ca892c4c4614bfa20e93411b86248f23a0ecb5 | ['ea072b9ef6774545a51a3ef3cba41408'] | I need to know if i create a web service using wso2 data service ,
1 )can we create a web service sending parameters to web service and get output?
Because i heard that wso2 data servide web services doesn't take any parameters.
2)we can perform only select operations. is it true ?
| 5ba2a782ea0549e9e6cac9dcf04974def858f82bb2d47a13a5cacb9f3136f4bd | ['ea072b9ef6774545a51a3ef3cba41408'] | I have view pager in my application.i need to show pdf files on each fragment in view pager.is there way to get a pdf view from mupdf ? normally we call mupdf as below
<PERSON> = Uri.parse("path to pdf file");
Intent intent = new Intent(context, MuPDFActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.setData(uri);
context.startActivity(intent);
So if i use mupdf for my app i have to call MuPDFActivity on each fragment.I think its not a correct way?
|
89e07a3c5d3ec9c3e48572d5e5b4d582d7b6315ed864582c41f0c0dd77926a6d | ['ea16c1b2e30c451593a9248eb06365a7'] | Another way to do it:
Expose the service on $rootScope:
$rootScope.service = service;
and then in a template:
<p>Hello {{service.getUsername();}}</p>
You can do this on app.run, and you will get the service in all the views of your app. You could use this method for Authentication services.
| 30049f584c2bcd9976e2fc4d88d6f6277e55e11a41210e4007b91ffe640b2f93 | ['ea16c1b2e30c451593a9248eb06365a7'] | I'm sure that this problem could happen and I fix it deleting the content of the Derived data folder of XCode.
I just want to add the steps of how to delete those files:
Don't Delete the DerivedData folder.
Go to preferences (Command ,) > Locations Tab
On Derived Data you are going to see the path, clic the right pointing arrow (that will open that location in Finder)
Close XCode
Select all the files inside the DerivedData Folder (do NOT select parent folder) and (Command Delete) or move them to the Trash and then Empty Trash
Open the project and you are done
I hope it helps someone
|
e27aaab385ba9bed7d14b24d059bc5037c831a928972980e2e0f45ab66dd2064 | ['ea19f0a9b727453ca81d8afa5dfdc3ca'] | Problem1:When i click login button i can log in,give status.but when i press logout button it does not logout.So,how will i logout from facebook?
Problem2:I got a string str.I want to pass it in facebook's textfield (like we send messages by intent).How will i do that.
main class:
`
public class MainActivity extends Activity {
private static String APP_ID = "xxxxxxx";
private Facebook facebook = new Facebook(APP_ID);
private AsyncFacebookRunner mAsyncRunner;
String FILENAME = "AndroidSSO_data";
private SharedPreferences mPrefs;
ImageButton btnFbLogin;
ImageButton btnFbLogout;
Button btnPostToWall;
String str="I want this to pass";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnFbLogin = (ImageButton) findViewById(R.id.btn_fblogin);
btnFbLogout = (ImageButton) findViewById(R.id.btn_fbLogout);
btnPostToWall = (Button) findViewById(R.id.btn_fb_post_to_wall);
mAsyncRunner = new AsyncFacebookRunner(facebook);
btnFbLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d("Image Button", "button Clicked");
loginToFacebook();
}
});
btnFbLogout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d("Image Button", "button Clicked");
logoutFromFacebook();
}
});
btnPostToWall.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
postToWall();
}
});
}
public void loginToFacebook() {
mPrefs = getPreferences(MODE_PRIVATE);
String access_token = mPrefs.getString("access_token", null);
long expires = mPrefs.getLong("access_expires", 0);
if (access_token != null) {
facebook.setAccessToken(access_token);
btnFbLogin.setVisibility(View.INVISIBLE);
btnFbLogout.setVisibility(View.VISIBLE);
btnPostToWall.setVisibility(View.VISIBLE);
Log.d("FB Sessions", "" + facebook.isSessionValid());
}
if (expires != 0) {
facebook.setAccessExpires(expires);
}
if (!facebook.isSessionValid()) {
facebook.authorize(this,
new String[] { "email", "publish_stream" },
new DialogListener() {
@Override
public void onCancel() {
}
@Override
public void onComplete(Bundle values) {
acess_token
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("access_token",
facebook.getAccessToken());
editor.putLong("access_expires",
facebook.getAccessExpires());
editor.commit();
btnFbLogin.setVisibility(View.INVISIBLE);
btnFbLogout.setVisibility(View.VISIBLE);
btnPostToWall.setVisibility(View.VISIBLE);
}
@Override
public void onError(DialogError error) {
}
@Override
public void onFacebookError(FacebookError fberror) {
}
});
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
facebook.authorizeCallback(requestCode, resultCode, data);
}
public void postToWall() {
facebook.dialog(this, "feed", new DialogListener() {
@Override
public void onFacebookError(FacebookError e) {
}
@Override
public void onError(DialogError e) {
}
@Override
public void onComplete(Bundle values) {
}
@Override
public void onCancel() {
}
});
}
public void logoutFromFacebook() {
mAsyncRunner.logout(this, new RequestListener() {
@Override
public void onComplete(String response, Object state) {
Log.d("Logout from Facebook", response);
if (Boolean.parseBoolean(response) == true) {
runOnUiThread(new Runnable() {
@Override
public void run() {
btnFbLogin.setVisibility(View.VISIBLE);
btnFbLogout.setVisibility(View.INVISIBLE);
btnPostToWall.setVisibility(View.INVISIBLE);
}
});
}
}
@Override
public void onIOException(IOException e, Object state) {
}
@Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
}
@Override
public void onMalformedURLException(MalformedURLException e,
Object state) {
}
@Override
public void onFacebookError(FacebookError e, Object state) {
}
});
}
}`
when i click the logout button it says:
`
08-14 14:46:59.849: D/Image Button(284): button Clicked
08-14 14:46:59.869: D/Facebook-Util(284): GET URL: https://api.facebook.com/restserver.php? method=auth.expireSession&format=json
08-14 14:47:00.399: D/Logout from Facebook(284): {"error_code":101,"error_msg":"Invalid application ID.","request_args":[{"key":"method","value":"auth.expireSession"},{"key":"format","value":"json"}]}
`
| 4097518c94082438a5d43c11645ec2ce3f3733e6fce2720da841c5c3d125711e | ['ea19f0a9b727453ca81d8afa5dfdc3ca'] | In my old emulator the program runs easily without any problem.So i thought the program is fine.But when i try it with new emulator/or other emulators it also runs.The problem starts when i click search button.when i click,program unexpectedly closed.Logcat says illegalstateexception and caused by: no such column as_id.But in my database the _id column exists.I can search in my old emulator without exception.Same code same database.Why it is happening?Why it runs in only one emulator? Any one please kindly tell how to solve the exception.
This is my java class where my program breaks
`
public class EmployeeList extends ListActivity {
protected EditText searchText;
protected SQLiteDatabase db;
protected Cursor cursor;
protected ListAdapter adapter;
public Integer pid=null;
public DatabaseHelper databaseHelper;
public Book book;
private static final int DELETE_ID = Menu.FIRST+3;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
db = (new DatabaseHelper(this)).getWritableDatabase();
searchText = (EditText) findViewById (R.id.searchText);
}
public void search(View view) { //when i click here i get exception
// || is the concatenation operation in SQLite
Toast.makeText(getApplicationContext(), "insert successfull", Toast.LENGTH_LONG).show();
cursor = db.rawQuery("SELECT _id, firstName, lastName, title FROM employee WHERE firstName || ' ' || lastName LIKE ?",
new String[]{"%" + searchText.getText().toString() + "%"});
adapter = new SimpleCursorAdapter(
this,
R.layout.employee_list_item,
cursor,
new String[] {"firstName", "lastName", "title"},
new int[] {R.id.firstName, R.id.lastName, R.id.title});
setListAdapter(adapter);
registerForContextMenu(getListView());
}
public void onListItemClick(ListView parent, View view, int position, long id) {
Intent intent = new Intent(this, EmployeeDetails.class);
Cursor cursor = (Cursor) adapter.getItem(position);
intent.putExtra("EMPLOYEE_ID", cursor.getInt(cursor.getColumnIndex("_id")));
startActivity(intent);
}
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenu.ContextMenuInfo menuInfo) {
menu.add(Menu.NONE, DELETE_ID, Menu.NONE, "Delete")
.setAlphabeticShortcut('d');
}
@Override
public boolean onContextItemSelected(MenuItem item) {
switch (item.getItemId()) {
case DELETE_ID:
AdapterView.AdapterContextMenuInfo info=
(AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
delete(info.id);
return(true);
}
return(super.onOptionsItemSelected(item));
}
private void delete(final long rowId) {
if (rowId>0) {
new AlertDialog.Builder(this)
.setTitle(R.string.delete_title)
.setPositiveButton(R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
processDelete(rowId);
}
})
.setNegativeButton(R.string.cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
// ignore, just dismiss
}
})
.show();
}
}
private void processDelete(long rowId) {
String[] args={String.valueOf(rowId)};
databaseHelper.getWritableDatabase().delete("employee", "_ID=?", args);
cursor.requery();
}
} `
my database class:
`public class DatabaseHelper extends SQLiteOpenHelper{
public static final String DB_NAME = "employee_directory";
public static final Integer VERSION=1;
public static final String TABLE_NAME= "employee";
public static final String _id= "id";
public static final String firstName= "firstName";
public static final String lastName= "lastName";
public static final String title= "title";
public static final String officePhone= "officePhone";
public static final String cellPhone= "cellPhone";
public static final String email= "email";
public static final String TABLE_SQL = "CREATE TABLE " + TABLE_NAME+" (" +_id+" INTEGER PRIMARY KEY AUTOINCREMENT, "
+ firstName+ " TEXT, " + lastName+ " TEXT, " + title+ " TEXT, " + officePhone+ " TEXT, " + cellPhone+" TEXT, " + email+" TEXT)";
public DatabaseHelper(Context context) {
super(context, DB_NAME, null, VERSION);
// TODO Auto-generated constructor stub
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
Log.d("TABLE SQL", TABLE_SQL);
db.execSQL(TABLE_SQL);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldV, int newV) {
db.execSQL("DROP TABLE IF EXISTS employees");
onCreate(db);
}
}`
my logcat says:
` 08-10 01:23:12.655: E/AndroidRuntime(337): FATAL EXCEPTION: main
08-10 01:23:12.655: E/AndroidRuntime(337): java.lang.IllegalStateException: Could not execute method of the activity
08-10 01:23:12.655: E/AndroidRuntime(337): at android.view.View$1.onClick(View.java:2072)
08-10 01:23:12.655: E/AndroidRuntime(337): at android.view.View.performClick(View.java:2408)
08-10 01:23:12.655: E/AndroidRuntime(337): at android.view.View$PerformClick.run(View.java:8816)
08-10 01:23:12.655: E/AndroidRuntime(337): at android.os.Handler.handleCallback(Handler.java:587)
08-10 01:23:12.655: E/AndroidRuntime(337): at android.os.Handler.dispatchMessage(Handler.java:92)
08-10 01:23:12.655: E/AndroidRuntime(337): at android.os.Looper.loop(Looper.java:123)
08-10 01:23:12.655: E/AndroidRuntime(337): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-10 01:23:12.655: E/AndroidRuntime(337): at java.lang.reflect.Method.invokeNative(Native Method)
08-10 01:23:12.655: E/AndroidRuntime(337): at java.lang.reflect.Method.invoke(Method.java:521)
08-10 01:23:12.655: E/AndroidRuntime(337): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-10 01:23:12.655: E/AndroidRuntime(337): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-10 01:23:12.655: E/AndroidRuntime(337): at dalvik.system.NativeStart.main(Native Method)
08-10 01:23:12.655: E/AndroidRuntime(337): Caused by: java.lang.reflect.InvocationTargetException
08-10 01:23:12.655: E/AndroidRuntime(337): at com.example.again.EmployeeList.search(EmployeeList.java:46)
08-10 01:23:12.655: E/AndroidRuntime(337): at java.lang.reflect.Method.invokeNative(Native Method)
08-10 01:23:12.655: E/AndroidRuntime(337): at java.lang.reflect.Method.invoke(Method.java:521)
08-10 01:23:12.655: E/AndroidRuntime(337): at android.view.View$1.onClick(View.java:2067)
08-10 01:23:12.655: E/AndroidRuntime(337): ... 11 more
08-10 01:23:12.655: E/AndroidRuntime(337): Caused by: android.database.sqlite.SQLiteException: no such column: _id: , while compiling: SELECT _id, firstName, lastName, title FROM employee WHERE firstName || ' ' || lastName LIKE ?
08-10 01:23:12.655: E/AndroidRuntime(337): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
08-10 01:23:12.655: E/AndroidRuntime(337): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
08-10 01:23:12.655: E/AndroidRuntime(337): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
08-10 01:23:12.655: E/AndroidRuntime(337): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
08-10 01:23:12.655: E/AndroidRuntime(337): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46)
08-10 01:23:12.655: E/AndroidRuntime(337): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
08-10 01:23:12.655: E/AndroidRuntime(337): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
08-10 01:23:12.655: E/AndroidRuntime(337): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1315)
08-10 01:23:12.655: E/AndroidRuntime(337): ... 15 more `
|
343dc56a1190edcba42201992447d664ee9684baaaa064738bd509aeca1b0a9c | ['ea20e0acb30f4c61aa9b3e6da986192c'] | I modified an Ansible play-book, and from git status I can clearly see the modified data/files. Now when I run the play-book, the changes do not come into effect even after the play-book has run completely.
I tried renaming the playbook file, and even removing the play-book file form the directory, still the play-book executes. Seems some sort of caching mechanism.
I often end up in this situation but not able to understand what goes wrong. Ansible version used is 1.7.1
| 5ab90eddf0c2d200552f2082fda16bd7fbf91f8c62cd76887ae9e51034cc4823 | ['ea20e0acb30f4c61aa9b3e6da986192c'] | Got it, I had multiple path entries in the ansible.cfg for roles_path parameter. Co-incidentally, for each path specified in the roles_path parameter, the repository also existed and as per design Ansible used the first match.
Hence every time I made changes in my repository, still the data would come from the other repositories.
|
4fd4e0fa706b9eddc668efcd6539b8ed36c644480c138a4dbcff98ac50d9dca6 | ['ea31b1dfa5b74458ab3386ab56177a14'] | What webframework/language are you using? If you use RoR or Sinatra or any other rake-based framework you can use heroku.com. If your using asp.net you can use appharbor.com, finally if your using php you can use phpfog.com.
What these hostingproviders have in common is that you deploy the website by pushing your code with git, while you won't be deploying directly from github you can just add one of the above mentioned hosts to your remote-list (in addition to github) and then push to that remote when you wish to deploy.
Another solution would be to add a post-receive-hook to github which then triggers whenever you push to github, in that post-recieve-hook you could tell the webhost to pull from the repo. This does however require you to have git installed on the webserver aswell as some kind of webinterface for the post-recieve-hook to post to.
| e4eb1ce2f068383cb5a484f1a61c6edddcba9255e5d7509b3d5d10b9016ed17f | ['ea31b1dfa5b74458ab3386ab56177a14'] | <PERSON> is right, the Split method on String your trying to use doesn't exist, it's only available for char arrays with no secondary argument. You have to resort to this version: http://msdn.microsoft.com/en-us/library/tabh47cf.aspx. Also you have to use parentheses around your arguments when calling none-f# .NET apis because the arguments in C# are defined as a tuple.
You could of cause define your own extension-method on String, this way you don't have to specify None all the time if that is your expected default behavior
type System.String with
member x.Split(separator : (string [])) = x.Split(separator, System.StringSplitOptions.None)
|
ed322d5e8037b0a9a3908cc071758d1edce270a4383b109721efbcbcdc3395c3 | ['ea3ad8c9cc5b4903a0ac315701ac6be2'] | @rene That would make sense, indeed. On the other hand, having a comprehensive list of filtered expressions would not really do any harm because it is already easy to avoid the filtering, as shown in some of the links (replacing characters, using "issue" instead, etc.). Furthermore, I'm not only interested in the filter, but also any other constraints that might apply to question titles because I think it would be interesting to have them all collected in one place or find that collection if it already exists. | 005c9d645074d4276987e815749d8f8cfa00a88fefbaff07a9c3f58ea83efd07 | ['ea3ad8c9cc5b4903a0ac315701ac6be2'] | I wrote one to request moderator intervention because I can't do much more than that with my rep. (The question was http://stackoverflow.com/questions/3923471/good-literature-on-unit-testing and I flagged it because it's just another question asking for literature, but neither spam nor inappropriate.) |
d9c4a6c38c2982a05328afddfbb53a24aaaebc7df6dad46eb0432add3008778f | ['ea479118c9214c68b9750faf0df737cd'] | How can I get a file count given a directory grouped by file type? The output might look something like
.txt: 4
.png: 16
.jpg: 32
This probably isn't difficult to achieve with a script, but is there functionality like this built into any of Windows's command line tools?
| e284d0e046de4271c75c52fe2de4a9f0e89559723d51f4f47dc8a2cfe1e5353c | ['ea479118c9214c68b9750faf0df737cd'] | How do I get the width and height of a window? Let's say I, an end user, open Chrome in a window, and then resize it. How can I, an end user, find out how large the window is now? Chrome is just an example; I am looking for how to do this with any application in a window.
|
de5d3172e39bb372ea165a55b6ef532ffd2133775f9aac0efc222ce03d4c56c2 | ['ea517663e03042a79be431dfb37be22d'] | I have installed Black&White free template from http://templatesforjoomla.eu/free-joomla-1.5-templates/blackandwhite-free-joomla-1.5-template.html
I really like this template and want to use it but I found a problem. It is not properly displayed on IE8 (it is said to work on IE7+). These are my problems that you also can see on the demo site
The slider works ok on everything except IE - only the picture is displayed without the text next to it
When the submenus on the top reach the picture in the slider - they hide behind it
I have some experience with joomla but IE has always be my nightmare. Thanks in advance for your help!
| 26f2ed3ab392af7eba77811817c3664707d0ded1cf0b9a624a2bd1aec2dac6bb | ['ea517663e03042a79be431dfb37be22d'] | I did some Google search but couldn't find what I was looking for. I start multiple async downloads at the same time and I want to check which file is downloaded. How can I achieve this?
Private Sub client_DownloadCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)
MsgBox("Download Completed!") ' I want to add the name of the downloaded file in this message
End Sub
Thanks in advance!
Regards
|
c583aea71fb6e44b820474aeaac6d0a7e8ce5c9339435a064409955b954193f3 | ['ea6b0dd666cb43029dc184125a43fd47'] | I created a simple mbed project and exported it as makefile project. From that point, I developed my application. Whenever I need something from mbed, i just include mbed.h file, and I have access to all nice objects like digitalOut, Timeout, etc.
When I wanted to create a test for a module, I realized, that #include "mbed.h" was very annoying.
I wanted to stub all those nice objects in the test anyway, but the errors just keep paling up, and I could not make the test to compile.
To overcome that issue I created proxy objects for the things that I use in my project, and I can swap their implementation by simple #if Test in the implementation, if the macro was not satisfied, I included mbed.h, and pass the parameters and result to it, but when it was satisfied, I did dummy implementation, which I could override by a stub in the test. In this approach I do not have to deal with #include "mbed.h" in tests, but I get a feeling, that it should not be necessary, and it is just another unnecessary level of abstraction.
I would like to ask How to make good stubs and Tests when I use Mbed, (or any other library - I want to test MY code, not the code of external library in unit tests) I thought that isolating libraries for tests, should be easy, but I'm stuck with this for a while, and I do not know how to do it the right way.
Let me give you a simple example what do I mean:
#include "mbed.h"
class A{
mbed<IP_ADDRESS>DigitalOut& pin;
public:
A(mbed<IP_ADDRESS>DigitalOut& p):pin(p){}
void toggle(){
pin = ~pin;
}
};
In this simple case, I use DigitalOut from mbed. To make it work I think that I should provide stub for the operator int() and operator=(int), because those are only functions that I used.
In fact It is not enough to compile a simple test because, under #inclued "mbed.h" there are many more objects, that need to be satisfied to link the binary. Is there any way to stub all those objects with dummy implementation, and link that to the test? - I Could then overwrite those implementations by google mock and use them in tests.
How should look like a stub file and test file for such a simple example? To be able to run the tests on x86
| 8d6563cfcfdd5aa003a8cf55d3d51efc829e298cab0497007d9895895a5ce6c6 | ['ea6b0dd666cb43029dc184125a43fd47'] | I was wandering, why there are no implementations of the devices written in CMSIS-Driver?
I mean that I have few peripherals: LCD, temperature and pressure sensor, current meter etc. - all of them very popular used in arduino and learning sets.
Each of these devices uses some protocol to communicate with the uC. some are for i2C, some communicate by SPI, some by UART. I was wondering if there are drivers that handle those devices, and as a backend use CMSIS-Driver API.
I think that it is a decent api, and after all standard develop by ARM, so why I can not find any drivers using it?
For example when I was looking for s18b20 (temperature sensor for 1-wire), I was easily able to find driver for this device written in RUST language, but I was not able to find any implementation for C that would use CMSIS. (in this case compare to rust is quite solid, because Rust has nice embedded API, and you can easily use the driver on multiple targets, just like CMSIS-Driver is spouse to work)
I was able to find some projects using this peripheral, but they all operated on HAL that is different for every uC, so the implementation is not portable ( unlike RUST, and potentially CMSIS-Driver)
So my main questions are:
Why there are so little implementations based on CMSIS-Driver? Maybe there is some hidden implementation repository that I do not know about?
Am I missing something? Is the CMSIS-Driver not designed for the casual developers? Who is it designed for then ?
|
8b97c09a1da68df38137245e3a7d7a7603931ade6cc93e012cb73212bf0c3a15 | ['ea7109c0ca8e4f878605602ef2b4185e'] | The following should be something well?-known, but i haven't seen it anywhere,
neither have i met any references about.
Let $M^{n}$ be a $n$-dimensional oriented closed manifold with a (sufficiently
small) triangulation $\tau$. We "colour" the vertices of $\tau$ with $n+2$
colors: $v^{o}\rightarrow w(v^{o})\in$ {$1,2,...,n+2$ } and we shall say that
the correspondence $w$ is a "coloring" of $\tau$. Take an arbitrary color
$i\in$ {$1,2,...,n+2$ } and consider the $n$-simplices whose vertices are
colored with exactly the colors {$1,2,...,n+2$ }$\backslash\{i\}$. Let
$\Delta^{n}$ be such a simplex and $v_{1},...,v_{n+1}$ be its vertices ordered
according to the positive orientation of $\Delta^{n}$ induced by the
orientation of $M^{n}$. Then we write $\sigma_{i}(\Delta^{n})=1$, if the
permutation $(w(v_{1}),...,w(v_{n+1}))$ is even, and $\sigma_{i}(\Delta
^{n})=-1$ otherwise. Set $\sigma_{i}(\Delta^{n})=0$ if some vertex of
$\Delta^{n}$ is colored $i$, or there are two identically colored vertices.
Let finally
$\sigma_{i}(w)=\sum\sigma_{i}(\Delta^{n})$,
where the sum is over all $n$-simplices.
The Claim: The number $\sigma_{i}(w)$ does not depend on $i$:
$\sigma_{1}(w)=\sigma_{2}(w)=...=\sigma_{n+2}(w)$. So we have a global invariant
$\sigma(w)$ of the coloring $w$.
This invariant has a geometrical meaning:
Consider the dual cell complex of the triangulation $\tau$, then since each
cell corresponds to a vertex $v^{o}$ of $\tau$, we may color this cell by the
color $w(v^{o})$. Let $F_{i}$ be the union of all cells colored $i$, then we
get a covering $\lambda=\{F_{1},...,F_{n+2}\}$ of $M^{n}$. It is easy to see
that the intersection of all $F_{i}$ is empty, so the canonical map of $M^{n}$
into the nerve of $\lambda$ may be considered as a map of $M^{n}$ into the
$n$-sphere $\mathbb{S}^{n}$:
$\varphi:M^{n}\rightarrow\mathbb{S}^{n}$. Then the degree of $\varphi$ equals
$\sigma(w)$:
$\deg\varphi=\sigma(w)$.
As the proofs are not sophisticated at all and the construction seems
conceptual, maybe it is worth including this material in an elementary
topology textbook. Note also that it gives a method for calculating the degree
without smooth approximation.
Of course, i don't want to repeat well-known things without citation, so any
references are welcome.
| e0b918bb6eb2cf45ffecafe34f0dc2773115bc1d7137741ad8033936a8d7dff7 | ['ea7109c0ca8e4f878605602ef2b4185e'] | thanks <PERSON> for the help. i really don't worry about the NEXT TRAVEL, i"m worried about this one, i traveled with both passport to the US before but it was always on the same name. the dillema was is the ticket should be on the israeli name or the german one, (and again, it's only the last name that's differant, the israeli passport shows the old one in brackets, the ESTA form stated my israeli passport name and number...), yet, american bureaucracy is not something i want to deal with on my vacation. thanks again |
fb319841ae2370b7dda233d7eebf04ace0c6d227acb6660822d55ef0c7248eb3 | ['ea798abef725473bac3c2bfdac9fdc4e'] | I ordered the cheapest model from Aftershokz. It came today, and I'm reasonably pleased with the indoor testing so far. One odd note: it can pair to two devices, but only play audio from one at a time. Head comfort also fine, but I've only gone two hours at a time. | e81582e4b31cf8848db95531ac6152704fccff3b98a7ed6e1b15d50785534324 | ['ea798abef725473bac3c2bfdac9fdc4e'] | Interview with Screewriter <PERSON>:
Batman Hush Uses Red Herrings To Fake Out Fans - SDCC 2019
The reason is two-fold:
Time constraints of condensing a 12-part mini-series into 70 minutes
Faking Out the audience to keep a familiar story fresh
The original story had a lot of red-herrings. Going with one of them as the actual new ending instead of a dead-end, allowed them to condense the story and surprise the audience.
|
5ae454e597445b8a0d5a649d7f332e7dced5dc02b0e6a41d0921bc9e73b2060f | ['ea9ff4cd4b2a477db2074f7957e8e91a'] | This should work in your specific case:
import pyspark.sql.functions as F
df = df.withColumn(
"arr", F.split(F.col("Name"), " ")
)
df = (
df
.withColumn('FirstName', F.arr.getItem(0))
.withColumn('MiddleName', F.arr.getItem(1))
.withColumn('LastName', F.arr.getItem(2))
)
If you want to include the case when someone has several middle names:
df = (
df
.withColumn('FirstName', df.arr.getItem(0))
.withColumn('LastName', df.arr[F.size(df.arr)-1])
)
df = df.withColumn(
'MiddleName',
F.trim(F.expr("substring(Name, length(FirstName)+1, length(Name)-length(LastName)-length(FirstName))"))
)
| 843c2a0a37e0632e46a9634948c386b3a45351e4c6055525844159d110d3e220 | ['ea9ff4cd4b2a477db2074f7957e8e91a'] | It is possible to have FPR = 1 with TPR = 1 if your prediction is always positive no matter what your inputs are.
TPR = 1 means we predict correctly all the positives. FPR = 1 is equivalent to predicting always positively when the condition is negative.
As a reminder:
FPR = 1 - TNR = [False Positives] / [Negatives]
TPR = 1 - FNR = [True Positives] / [Positives]
|
40bc22f1acbcb20b71aee3d9ec9009653b97da63339de2fdc48836056e4e5e62 | ['eaa47b8604f241a788743e3e6d04a710'] | I have a subscription form that contains a matrix of options. The form can be seen in screenshot Subscription table
I am having trouble with ASP.NET MVC generating appropriate ID's and then on postback having the binder populate the model with the form selections.
The add on name is down the left side and when posted back the collection of SubscriptionInputModel.Addons get populated ok. But SubscriptionInputModel.Addons[i].SubscriptionLevelCombos is null as seen in debug screenshot
The current code is using CheckBoxFor but I've also tried manually generating ID's in format:
@Html.CheckBox("addon[" + a + "].SubscriptionLevelCombo[" + i + "].AddonSelected", addon.SubscriptionLevelCombos[i].AddonSelected)
Neither format has worked and also experimented while debugging but no luck. I would appreciate any ideas. Worst case I assume I would need to read the raw form collection?
I assume the level of nested object shouldn't matter as it is all object path notation and array indexes in html tag names?
Here are snippets of current code to help illustrate what exists.
View Models
public class SubscriptionInputModel
{
//other stuff to come
//....
//add on's, listed down left of table
public List<SubscriptionInputAddonModel> Addons;
}
public class SubscriptionInputAddonModel
{
public int Id { get; set; }
public string Name { get; set; }
public string Note { get; set; }
public List<SubscriptionInputAddonComboModel> SubscriptionLevelCombos { get; set; }
}
public class SubscriptionInputAddonComboModel
{
public int? Id { get; set; }
public decimal? AddonCost { get; set; }
public CostTimeUnitOption? CostTimeUnit { get; set; }
public bool? IsComplimentaryBySubscriptionLevel { get; set; }
public string ComboText { get; set; }
public bool AddonSelected { get; set; }
public int? AddonId { get; set; }
}
SubscriptionController
[Route("identity/subscription")]
// GET: Subscription
public ActionResult Index()
{
SubscriptionInputModel model = new SubscriptionInputModel();
ArrbOneDbContext db = new ArrbOneDbContext();
List<SubscriptionInputAddonModel> addons = Mapper.Map<Addon[], List<SubscriptionInputAddonModel>>(db.Addons.OrderBy(a => a.OrderPosition).ToArray());
model.Addons = addons;
foreach(var addon in model.Addons)
{
var addonCombos = db.Database.SqlQuery<SubscriptionInputAddonComboModel>(@"SELECT SLA.Id, AddonCost, CostTimeUnit, IsComplimentaryBySubscriptionLevel, ComboText, AddonId
FROM SubscriptionLevel L
LEFT OUTER JOIN SubscriptionLevelAddon SLA ON L.Id = SLA.SubscriptionLevelId AND SLA.AddonId = @p0
ORDER BY L.OrderPosition", addon.Id);
addon.SubscriptionLevelCombos = addonCombos.ToList();
}
return View(model);
}
[Route("identity/subscription")]
[ValidateAntiForgeryToken]
[HttpPost]
// POST: Subscription
public ActionResult Index(SubscriptionInputModel model)
{
ArrbOneDbContext db = new ArrbOneDbContext();
List<SubscriptionInputAddonModel> addons = Mapper.Map<Addon[], List<SubscriptionInputAddonModel>>(db.Addons.OrderBy(a => a.OrderPosition).ToArray());
model.Addons = addons;
//debug breakpoint to inspect returned model values
return View();
}
Index.cshtml
@model Identity_Server._Code.ViewModel.Subscription.SubscriptionInputModel
@{
ViewBag.Title = "Subscription";
}
@using (Html.BeginForm("Index", "Subscription", new { signin = Request.QueryString["signin"] }, FormMethod.Post))
{
@Html.ValidationSummary("Please correct the following errors")
@Html.AntiForgeryToken()
...
// ADD ONs ----------------------------------------------------------------------------------
@for (int a = 0; a < Model.Addons.Count; a++)
{
var addon = Model.Addons[a];
<tr>
<td class="text-left">@addon.Name
<div class="SubscriptionItemNote">@addon.Note
@Html.HiddenFor(m => m.Addons[a].Id)
</div>
</td>
@for (int i = 0; i < addon.SubscriptionLevelCombos.Count; i++)
{
<td>
@if (addon.SubscriptionLevelCombos[i].Id.HasValue)
{
if (addon.SubscriptionLevelCombos[i].AddonCost.HasValue && addon.SubscriptionLevelCombos[i].AddonCost.Value > 0)
{
@Html.Raw("<div>+ " + @addon.SubscriptionLevelCombos[i].AddonCost.Value.ToString("0.##") + " / " + @addon.SubscriptionLevelCombos[i].CostTimeUnit.Value.ToString() + "</div>")
}
else if (addon.SubscriptionLevelCombos[i].IsComplimentaryBySubscriptionLevel.HasValue && @addon.SubscriptionLevelCombos[i].IsComplimentaryBySubscriptionLevel.Value)
{
<span class="glyphicon glyphicon-ok"></span>
}
if (!string.IsNullOrEmpty(addon.SubscriptionLevelCombos[i].ComboText))
{
<div>@addon.SubscriptionLevelCombos[i].ComboText</div>
}
if (addon.SubscriptionLevelCombos[i].AddonCost.HasValue && addon.SubscriptionLevelCombos[i].AddonCost.Value > 0)
{
@Html.HiddenFor(m => m.Addons[a].SubscriptionLevelCombos[i].Id)
@Html.CheckBoxFor(m => m.Addons[a].SubscriptionLevelCombos[i].AddonSelected)
}
}
</td>
}
</tr>
}
| eb59dda916cbdeb676b37fbd17ae8bea30d1e1dad69b7d0373b4858f30035288 | ['eaa47b8604f241a788743e3e6d04a710'] | Found solution, not very easy to find in documentation. Needed to created a WhereCondition and pass that as where in query.
var localityWhereCondition = new WhereCondition().WhereLike("Suburb", locationLike)
.Or()
.WhereLike("Postcode", locationLike)
.Or()
.WhereLike("State", locationLike)
.Or()
.WhereLike("Suburb + ', ' + State + ', ' + Postcode", locationLike);
var locationsQuery = CustomTableItemProvider.GetItems("customtable.ProjectName_PostcodeSuburb")
.WhereNotNull("Latitude")
.And()
.WhereNotNull("Longitude")
.And()
.Where(localityWhereCondition)
.Columns("Suburb, State, Postcode")
.OrderBy("Suburb, State, Postcode")
.TopN(20);
|
5374c2ef7772ff8473caa3008b656149e0d4d19a10bbb7952370588966f70be6 | ['eaaefff95eff4659b0e0a27ef1c20391'] | Ok well I fixed one problem and found a work around for another. To fix the USBs I used the clear CMOS button on my motherboard. That was literally the only thing that would work. As for the slow startup, unplugging the power cable for 5 minutes, plugging it back in and booting up fixed it. It now passes the motherboard splash screen in under 2 seconds. Only problem is the slow boot problem congress back every so often and I have to drain the power again.
| 484ec163750f511ed3268c6cf41e50a4bcbdbd75c93b5630a1ad732f99b70da5 | ['eaaefff95eff4659b0e0a27ef1c20391'] | I am a first day ubuntu user. I really want to like it but I have had major issues. Right after installing I realize my RAT 7 mouse was not fully compatible and out took me 2 days to fix it. In doing so, 4/6 USB drives stopped working, and during startup I get stuck on the mobo splash screen for a long time before the mouse and keyboard light up and start working. I have tried reinstalling ubuntu already and the usbs do not work on live ubuntu. I'm not sure what information I should give. I'm very very new to ubuntu. My motherboard is asrock z97 extreme 6. 16gb ram. Intel i7 4790k. I have googled for the last 3 days with no progress. Thank you for any help. My partitions have / on an ssd. And /home /swap and /usr on an hdd.
|
a6d6268e805be6e767a8dee8f57b2cf7eadedf40963432b7396059c0d470b0f5 | ['eabf4102450e483981a56875ab51e42f'] | Learning programming and trying to understand this example.
Given multiple independent events, each with a probability of occurring, what is the probability of just one event occurring?
If we have 2 cases I can understand it this way:
P(exactly one event occurs) = P(a and not b) + P(not a and b)
Calculated as:
(Pa)*(1-Pb) + (Pb)*(1-Pa)
Can it be explained why we use (1-probability) here? What does subtracting the prob. from 1 "do"?
Thank you.
Generalized as:
n
∑ pi (1 − p1 )...(1 − pi−1 )(1 − pi+1 )...(1 − pn )
i=1
Coded in R as:
exactlyone <- function(p) {
notp <- 1 - p
tot <- 0.0
for (i in 1:length(p))
tot <- tot + p[i] * prod(notp[-i])
return(tot)
}
| b839cc6d413614a657f69711615b9aea64e7956fcb821d7629326f4d37007426 | ['eabf4102450e483981a56875ab51e42f'] | I have installed Ubuntu 13.04 on a Lenovo T430s. I connected an external monitor via the VGA port (Samsung SyncMaster 2443). When I go to the Display settings, the monitor appears as "unknown", and the maximum resolution is 1024 x 768.
(The maximum resolution is 1920 x 1200 on Windows 7.)
I tried turning Optimus mode on/off, I tried installing Bumblebee, and I tried installing the latest Intel drivers through intel-linux-graphics-installer, to no avail. How can I get Ubuntu to recognize the monitor and/or enable a higher resolution?
|
d5304a0bb8596d9cf869699600e531f7e7ccc2395640fde04cfd330a08d0345e | ['eac7a0afa87d41ac8737bece6b2e2932'] | I've been going crazy over this and I think the answer is probably out there but I don't know the right way to ask Google the question.
Essentially I need a way to make a $resource call, and pass in some data that I want to then use in the success function.
app.controller('VariantListController', ['djResource', function(djResource){
var Variants = djResource('/ship-builder/variants/?format=json');
var Vehicle = djResource('/ship-builder/vehicles/:id', {id: '@id'});
this.variants = Variants.query(function(variants){
$(variants).each(function(){
console.log(this);
variantData = this;
var vehicleData = Vehicle.get({id:this.baseVehicle}, function(){
console.log(variantData);
})
})
});
}]);
In the above example, in the innermost success function, 'variantData' is always the value of the LAST entry from the previous level. This makes sense because the value was set by the last item in the array long before the success happens. I need a way though to have the value of the 'variantData' that was inexistince when the Vehicle.get() was called.
Does that make sense? I find it very hard to explain the issue.
| c6a2323cd4c60570eaffa23b0c707d3d9b2c5007f328c55f69e0587a5a1506c1 | ['eac7a0afa87d41ac8737bece6b2e2932'] | For the sake of reusable code, I am trying to avoid having to hardcode literally thousands of complex objects by instead using strings like "foo.bar.sub" to access properties.
Now I have quickly worked out a naive algorithm for getting the value of a property, like so:
getValueForPath : function(path) {
var pathArray = path.split('.'),
modelCopy = this;
while (pathArray.length > 0) {
modelCopy = modelCopy[pathArray.shift()];
}
return modelCopy;
},
However this will only return the value of a property, not let me set the value of a property. So it is only one half of the problem. Ideally I need a way to, for a given path, return the property itself, which i'm not sure is possible in JavaScript(But i'm not a JavaScript expert), or I need a second function to set the property for a given path, and I have so far been unable to work this out.
Any thoughts?
|
c933dab30a2e508ed5a7ae163ee8b9c9654f7a395a9653dc643987fa44439a0f | ['eac8a3ded122419ab34092659839deb8'] | I am using readxl and lapply to import multiple .xlsx files into my environment. The following worked perfectly before but now when I try to re-run it, it gives me the following error:
Error in read_fun(path = path, sheet = sheet, limits = limits, shim = shim, :
Evaluation error: zip file 'data.xlsx' cannot be opened.
Code:
setwd("./Data Folder") #set path in order to avoid lapply error (This is what solved it last time I got errors)
Load all "Data Folder" datasets
library(readxl)
file.list <- list.files(path = "./Data Folder", pattern = '*.xlsx')
df.list <- lapply(file.list, read_excel)
I have checked if the path I entered is still correct and I didn't alter it by mistake. I have also tried to open the documents in the folder using excel and there is no problem with the files. Any ideas?
| 4e85244d85275e928453201f0ec4d3787602994b4b4baf5a0745492839063e50 | ['eac8a3ded122419ab34092659839deb8'] | I am trying to merge multiple rows from a dataset into one. I would like to fill the NA's where data is available but also keep the various entries when multiple entries are available.
The data has the following structure:
data.frame(ID = c(1,2,3,4), D_1=c("data1",NA,NA,"data1"), D_2=
c(NA,"data2",NA,NA), D_3 = c("data3",NA,"data3",NA), D_4 =
c("data4","data4",NA,"data4"), FACT = c("A","B","C","D"))
The methods I found to work require the columns to be character columns so(my columns are character too):
dat$D_1 <- as.character(dat$D_1)
dat$D_2 <- as.character(dat$D_2)
dat$D_3 <- as.character(dat$D_3)
dat$D_4 <- as.character(dat$D_4)
Desired output:
I would like a column, lets call it "D" which would have all the data available:
Dat$D = (`data1, data3, data4`, `data2, data4`, `data3`, `data1, data4`)
I have used:
library(dplyr)
dat <- dat %>%
mutate(D = coalesce(D_1, D_2, D_3, D_4))
This is the result:
dat$D = (data1, data2, data3, data1)
I have also tried functions from tidyverse with no luck:
library(tidyverse)
dat <- dat1 %>% gather(2, 3) %>%
filter(value) %>%
group_by(name) %>%
summarise(color=paste(key,collapse=",")) %>%
right_join(dat1)
This gives me an error:
Error in filter_impl(.data, quo) :
Evaluation error: object 'value' not found.
In addition: Warning message:
attributes are not identical across measure variables;
they will be dropped
Also tried:
D <- with(dat, pmax(D_1, D_2, D_3, D_4))
The resulting column has all NA's
Thanks
|
2b501fbdf7094753ab9d8a061bf25da8669f645b5121ae1a0aba8af44ea53b55 | ['eacbc5f4beb2468e85d89cf2fa17f065'] | I want to do a defragment operation on my drive but I want it to be outside windows. This way, there will be no conflicts between files in-use and other issues.
Is a defragment operation the same thing as copying files from a drive to another, formatting that drive and re-copy those files back?
What about overhead and stress? format--copy-back vs a regular defragmentation?
Thank you
| 2d1cf8a264edcd003778970eeedfbb22b10e3a0206077a90de40d363ecb9fb59 | ['eacbc5f4beb2468e85d89cf2fa17f065'] | Try this:
Open regedit.exe and navigate to:
HKEY_CURRENT_USER\Software\Microsoft\Command Processor
Add two REG_DWORD values if they do not exist: CompletionChar and PathCompletionChar.
Edit their values to "9" (sans-quotes) and restart the computer.
After reboot, try to use the TAB key to autocomplete.
Other than that there is no way for command to use an automatic autocomplete.
|
3188a6312cf066d36a7928c2b75d279da8a3959fbe61192a1fc256a0f7e580c1 | ['eada9f8111c448328c768237d1dac85d'] | I think I'm getting confused with terminology. I have a site www.domain.com. Full of content and fully indexed by Google. I now want to run an ftp site on the same server. It is already setup and working great. If someone ftp's to www.domain.com it works great. Now I just want to change it so that users type in ftp.domain.com. So I guess the content is not the same as it is just an ftp server running on port 21. So I think your original advice stands...just create a subdomain? | 4ae6d56ddefa0b60cad47e9c913b72c4956ece62503061b7e4ea9b1639e8b4c7 | ['eada9f8111c448328c768237d1dac85d'] | This is driving me insane. There are many posts on this but nothing is working for me. I want to check if a file is not an avi or mpg then I want to exit. Here is a simple example:
#!/bin/sh
extension="avi"
if [ $extension != "avi" ] || [ $extension != "mpg" ]; then
echo "ERROR: File is not an avi or mpg"
exit 1
fi
echo "I should print out"
This always returns the ERROR message which it shouldn't. I've also tried:
if [[ $extension != "avi" ]] || [[ $extension != "mpg" ]]; then
if ([[ $extension != "avi" ]] || [[ $extension != "mpg" ]]); then
if [ $extension != "avi" -o $extension != "mpg" ]; then
What am I missing?
|
96cd65ed4473a79457fee707a827bd393b1d3c9f4e2ab881c478d3ca514a3e2a | ['eaddd2ad6b4a482d8d92e47915255ae6'] | I'm trying to add an event to my calendar using the code below but I keep getting errors about needing to refresh the token. I wasted a lot of time this morning using the wrong version of the api and having problems with autoload but I seem to be getting closer to a working code. I don't code in php much so please forgive any stupid mistakes.
Uncaught exception 'Google_Auth_Exception' with message 'Error
refreshing the OAuth2 token, message: '{ "error" : "invalid_grant"
The code I'm using is:
<?php
function calendarize ($title, $desc, $ev_date, $cal_id) {
session_start();
/************************************************
Make an API request authenticated with a service
account.
************************************************/
set_include_path( '../google-api-php-client/src/');
require_once 'Google/autoload.php';
require_once 'Google/Client.php';
require_once 'Google/Service/Calendar.php';
//obviously, insert your own credentials from the service account in the Google Developer's console
$client_id = 'xxxx.apps.googleusercontent.com';
$service_account_name = '<EMAIL_ADDRESS>';
$key_file_location = '../google-api-php-client/xxxx4.p12';
if (!strlen($service_account_name) || !strlen($key_file_location))
echo missingServiceAccountDetailsWarning();
$client = new Google_Client();
$client->setApplicationName("dsaccalendar");
if (isset($_SESSION['service_token'])) {
$client->setAccessToken($_SESSION['service_token']);
}
$key = file_get_contents($key_file_location);
$cred = new Google_Auth_AssertionCredentials(
$service_account_name,
array('https://www.googleapis.com/auth/calendar'),
$key
);
$client->setAssertionCredentials($cred);
if($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion($cred);
}
$_SESSION['service_token'] = $client->getAccessToken();
$calendarService = new Google_Service_Calendar($client);
$calendarList = $calendarService->calendarList;
//Set the Event data
$event = new Google_Service_Calendar_Event();
$event->setTimeZone('Europe/London');
$event->setSummary($title);
$event->setDescription($desc);
$start = new Google_Service_Calendar_EventDateTime();
$start->setDateTime($ev_date);
$event->setStart($start);
$end = new Google_Service_Calendar_EventDateTime();
$end->setDateTime($ev_date);
$event->setEnd($end);
$createdEvent = $calendarService->events->insert($cal_id, $event);
echo $createdEvent->getId();
}
calendarize('Test Event2','some stuff 2about the test event','2016-01-01T19:15:00','<EMAIL_ADDRESS>');
?>
| ac5b20bed5892819a1f87558645a36776371d63a075ed3a6b21fb3e3696b72c8 | ['eaddd2ad6b4a482d8d92e47915255ae6'] | I'm having problems sending email to yahoo.com email addresses, the mail I send from my php script works perfectly for every other domain i send it to apart from one of our users who insists on keeping her yahoo email.
here are my headers
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "Date: $date";
$headers[] = "From: 'DSAC Events' <$from>";
$headers[] = "Reply-To: <$replyto>";
$headers[] = "Subject: {$subject}";
$headers[] = "Return-Path: <$from>";
$headers[] = "X-Priority: 3";//1 = High, 3 = Normal, 5 = Low
$headers[] = "X-Mailer: PHP/" . phpversion();
mail($to, $subject, $msg, implode("\r\n", $headers));
I've read lots posts about people with the same problem, I've tried adding a message-id and return-path I've added the date: after reading that might be the problem and various other things to no avail.
Here is an example of the bounced mail source.
Return-path: <>
Envelope-to: <EMAIL_ADDRESS>
Delivery-date: Sat, 08 Nov 2014 14:41:32 +0000
Received: from mailnull by zeus1.easy-internet.co.uk with local (Exim 4.82)
id 1Xn7Cm-001cxb-8a
for <EMAIL_ADDRESS>; Sat, 08 Nov 2014 14:41:32 +0000
X-Failed-Recipients: <EMAIL_ADDRESS>
Auto-Submitted: auto-replied
From: Mail Delivery System <<EMAIL_ADDRESS>>
To: <EMAIL_ADDRESS>
Subject: Mail delivery failed: returning message to sender
Message-Id: <<EMAIL_ADDRESS>>
Date: Sat, 08 Nov 2014 14:41:32 +0000
This message was created automatically by mail delivery software.
A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:
<EMAIL_ADDRESS>
SMTP error from remote mail server after end of data:
host mta6.am0.yahoodns.net [63.250.192.46]: 554 Message not allowed - Headers are not RFC compliant[291]
------ This is a copy of the message, including all the headers. ------
Return-path: <<EMAIL_ADDRESS>>
Received: from d11dsa by zeus1.easy-internet.co.uk with local (Exim 4.82)
(envelope-from <<EMAIL_ADDRESS>>)
id 1Xn7Ci-001cl4-9S
for <EMAIL_ADDRESS>; Sat, 08 Nov 2014 14:41:29 +0000
To: <EMAIL_ADDRESS>
Subject:
X-PHP-Script: www.dsa.co.uk/eventmail.php for 2.218.47.72
MIME-Version: 1.0
Content-type: text/plain; charset=iso-8859-1
Date: Sat, 08 Nov 2014 14:41:28 +0000
From: DSACEvents <<EMAIL_ADDRESS>>
Reply-To: <<EMAIL_ADDRESS><IP_ADDRESS><IP_ADDRESS><PHONE_NUMBER>]: 554 Message not allowed - Headers are not RFC compliant[291]
------ This is a copy of the message, including all the headers. ------
Return-path: <d11dsa@zeus1.easy-internet.co.uk>
Received: from d11dsa by zeus1.easy-internet.co.uk with local (Exim 4.82)
(envelope-from <d11dsa@zeus1.easy-internet.co.uk>)
id 1Xn7Ci-001cl4-9S
for user@yahoo.com; Sat, 08 Nov 2014 14:41:29 +0000
To: user@yahoo.com
Subject:
X-PHP-Script: www.dsa.co.uk/eventmail.php for 2.218.47.72
MIME-Version: 1.0
Content-type: text/plain; charset=iso-8859-1
Date: Sat, 08 Nov 2014 14:41:28 +0000
From: DSACEvents <events@dsa.co.uk>
Reply-To: <person@live.co.uk>
Subject:
X-Priority: 3
|
e801e63a4f8b349cddf026c792a7686a12ec4e50f916bb5f7a9463ed7615a958 | ['eae0a420f74841bc96f3f34e8e7759a1'] | I looked around for webview plugins that support video and the Unity 3D webview plugin for Android is the only one I could find that does. I've been using it for a while now and would recommend it. Here's an example of using it:
using UnityEngine;
using Vuplex.WebView;
class SceneController : MonoBehaviour {
// I set this in the editor to reference a webview in the scene
public WebViewPrefab webPrefab;
void Start() {
webPrefab.Init(1.5f, 1.0f);
webPrefab.Initialized += (sender, args) => {
// load the video so the user can interact with it
webPrefab.WebView.LoadUrl("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
};
}
}
| 71d863cae48e4c04a54eb7d5775b400d54ae47e0f7029a02d3b74ee0c4bc1887 | ['eae0a420f74841bc96f3f34e8e7759a1'] | Yes, this is possible. If you set the Target API to "Automatic (highest installed)", Unity will use the highest version of the Android SDK that it detects on your system. For example, when I build using that setting in Unity 5.6, it uses API Level 28, since that is the highest version of the Android SDK that I have installed on my machine.
|
3521ba69e4384e279d09b9d447fc22fed932f96f3836b840f15d6ce5af1048a6 | ['eaf05e28a34b438b87d91315b63f0ca1'] | A simple workaround is to pass in the timestamp pre-formatted. At least for ISO timestamps, you can pass date.toISOString() as a separate parameter to the message.
var IntlMessageFormat = require('intl-messageformat'); // no matter, which NPM package to use
var icu_string = 'Hello, {username}, it is {ts, date} (ISO-timestamp is {tsiso})'
var formatter = new IntlMessageFormat(icu_string, 'en');
var date = new Date();
var output = formatter.format({
username: '<PERSON>',
ts: date,
tsiso: date.toISOString()
});
console.log(output);
Both intl-messageformat and format-message have a way to define a custom format, based however on Intl.DateTimeFormat options, instead of ICU's SimpleDateFormat.
| 3037dca8b0a40ac644965de3cdc6cf6c5be86f530247379fa3743d4440473daa | ['eaf05e28a34b438b87d91315b63f0ca1'] | The select argument type is an exact string match. You would need to make sure that you are passing a string argument value, and then have clauses that match. Avoid using plurals for exact case matching, since each locale has its own rules for what one means.
The following should give you what you want, but I know much more about the format than the PHP implementation.
MessageFormatter<IP_ADDRESS>formatMessage($locale,
'{0, select, _0 {a} _1 {b} other {c}}',
array( "_$value" ))
|
eb6bd881cb7f201c6260685292c0400b3a924f0523d7814f95c26f898a85504b | ['eaf35375f473456c8cb916b7996a2e68'] | Here is the Nginx setup I use for Laravel sites.
server {
listen 80;
listen [<IP_ADDRESS>]:80 ipv6only=on;
server_name SITE_URL;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
rewrite_log on;
access_log on;
root WEB_ROOT;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# Remove trailing slash.
if (!-d $request_filename) {
rewrite ^/(.+)/$ /$1 permanent;
}
location ~* \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# We don't need .ht files with Nginx.
location ~ /\.ht {
deny all;
}
}
| 0f7a64479804ace186e65fb63a8fb27418d5309d53d37ca1c4bcaa40a69dc2c5 | ['eaf35375f473456c8cb916b7996a2e68'] | This is my simple solution.
Place this code in the renderView function (around line 368 in version 1.5.4)) before ignoreWindowResize--; near the end of the function.
var lammCurrentDate = new Date();
var lammMinDate = new Date( lammCurrentDate.getFullYear(), lammCurrentDate.getMonth(), 1, 0, 0, 0, 0);
if (currentView.start <= lammMinDate){
header.disableButton('prev');
} else {
header.enableButton('prev');
}
|
7b4040b0eb3b99855e06507a24f3eb1d08de6ec35be8373eac3591e754ecb99f | ['eaf9b16edbff4aef9548b1e5612d6d33'] | It's a matter of roles and responsibilities.
In the first approach that Role takes on the responsibility of adding a message to the conversationList, but it should really be the responsibility of the Conversation objects.
In the second approach you delegate that responsibility to the Conversation object.
You tell the Conversation object to store a Message and that's it, you don't care how it's done.
| 6adb2456fcceeb3763641465268ae1a33b9b546b69d90f09e2b7fca82f2c356e | ['eaf9b16edbff4aef9548b1e5612d6d33'] | Make sure none of the App init calls generates any exceptions.
Then try if this helps:
$(function () {
App.init();
App.initNavMenu();
//Tabs
App.InitCustomTabs();
App.initMarqueeBrands();
//set equal height of two div's
var leftbar = $(".pg-left-bar :first").height() - 20;
var rightbar = $(".pg-right-bar :first").height() - 4; // remove 4 pxels from righ div
if (leftbar > rightbar)
{
leftbar = leftbar + 10;
$(".pg-right-bar").css({ "height": leftbar });
$(".pg-left-bar").css({ "height": leftbar });
}
else
{
$(".pg-left-bar").css({ "height": rightbar});
$(".pg-right-bar").css({ "height": rightbar });
}
//activatte tooltip
$('.tooltip').tooltipster();
});
|
0f2b67f1015c9df8c3dc69542530840878d2a6c5f947b266991031b733b20939 | ['eaff9d243451444dace73d2dd3ed362c'] | In order to get back to English, I had to change my locale in 3 places:
/etc/default/locale
by running this command:
$ sudo update-locale LANG=en_US.UTF-8 LANGUAGE= LC_MESSAGES= LC_COLLATE= LC_CTYPE=
~/.config/plasma-localerc and ~/.config/plasma-locale-settings.sh
By going to my KDE settings / Regional Settings / Language
And reboot.
| ca279254aeffed959c0dafdd25260674a0cb9d46ec3948705b57d14c17816ef6 | ['eaff9d243451444dace73d2dd3ed362c'] | One day seems reasonable, but if you get bored easily, you can spend only half a day. It is very beautiful in Keukenhof, and not too crowded to enjoy the view. No, the line was not too long when we visited.
One day seems a bit of a stretch though, depending on what time you want to get there. 3/4 is more like it, but it depends on a person.
|
bf3d0a4472d0ac25b25e5571279b600b8c5bb0bce1a42163477004c3daf9fe89 | ['eaffd063e5664365932fffce6539d52c'] | I use this code for Android give it a try :(it resize the page size )
import flash.display.MovieClip;
import flash.media.StageWebView;
import flash.geom.Rectangle;
import flash.events.Event;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.system.Capabilities;
this.visible = false ;
var webView: StageWebView = new StageWebView();
webView.stage = stage;
function videoing(VID): void {/// VID is the video id
stage.setAspectRatio(StageAspectRatio.LANDSCAPE);
var vidLink:String = "https://www.youtube.com/embed/"+ VID +"?autoplay=1" ;
trace(vidLink);
webView = new StageWebView();
webView.stage = this.stage;
webView.viewPort = new Rectangle(-(stage.stageHeight/2)+100,0, stage.stageHeight*2+40 , stage.stageWidth*2 - 160);
webView.loadURL(vidLink);
this.stage.focus = stage;
}
//////////////// dispose the video ///////////////////////
exit_btn.addEventListener(KeyboardEvent.KEY_DOWN, fl_OptionsMenuHandler);
function fl_OptionsMenuHandler(event: KeyboardEvent = null ): void {
if ((event.keyCode == Keyboard.BACK) && (webView)) {
event.preventDefault();
webView.stage = null;
webView.dispose();
webView = null ;
stage.setAspectRatio(StageAspectRatio.PORTRAIT);
}
}
On Android it needs to add
<application android:hardwareAccelerated="true"/>
| 82d68d77c8035f4f26e3bb6ab4bd169b83d1cf7d774282a4049462d4f6c0df59 | ['eaffd063e5664365932fffce6539d52c'] | Try this
import flash.utils.Timer;
import flash.events.TimerEvent;
var degree: Number = 90;
var degChange: Number = 1;
var circleR: Number = 100;
var circleX: Number = 100;
var circleY: Number = 100;
var angleR: Number = circleR / 4;
var spBoard: Sprite = new Sprite();
spBoard.x = circleX;
spBoard.y = circleY;
C1.Maskmc.addChild(spBoard);
var shFill: Shape = new Shape();
shFill.graphics.lineStyle(1, 0x000000);
shFill.graphics.moveTo(0, 0);
shFill.graphics.lineTo(circleR, 0);
shFill.x = 0;
shFill.y = 0;
shFill.graphics.clear();
shFill.graphics.moveTo(0, 0);
shFill.graphics.beginFill(0xFF00FF, 1);
var shAngle: Shape = new Shape();
spBoard.addChild(shFill);
function updatePicture(t: Number): void {
var radianAngle: Number //=// t * Math.PI / 180.0;
var i: int;
i = clockTimerTRas.currentCount ;
shFill.graphics.lineTo(circleR * Math.cos(i * Math.PI / 180), -circleR * Math.sin(i * Math.PI / 180));
trace(i)
}
var TurnoActual_A: int = (100) ;
var clockTimerTRas: Timer = new Timer(10, TurnoActual_A);
clockTimerTRas.addEventListener(TimerEvent.TIMER, UpdateP);
clockTimerTRas.start();
function UpdateP(evt: Event): void {
var TurnoEstaHora
degree = TurnoActual_A * (11.305)
updatePicture(degree);
}
|
05e8953c2d0a8ddf3f99d47b9ea68103c75a041591e20c1c9f6251809d03acf8 | ['eb0132d22975436b87f633e42b559551'] | I have been trying to figure out a way to pause my audio with a button (very simple, just on click backgroundMusic.stop()) but it doesn't pause. With the code below the idea is that it runs from the opening of the app but when I load the scene again it won't play on top of the previous track. All the code below is doing is printing 'play' every time I load the scene and I get multiple tracks playing over each other so it seems it is unable to detect is the audio is playing or not. This is my first time using audio in xcode so I'm unfamiliar with it. I am using xCode 7.0.1 and Swift 2.
Inside my ViewController class but outside my ViewDidLoad:
func setupAudioPlayerWithFile(file:NSString, type:NSString) -> AVAudioPlayer? {
//1
let path = NSBundle.mainBundle().pathForResource(file as String, ofType: type as String)
let url = NSURL.fileURLWithPath(path!)
//2
var audioPlayer:AVAudioPlayer?
// 3
do {
try audioPlayer = AVAudioPlayer(contentsOfURL: url)
} catch {
print("Player not available")
}
return audioPlayer
}
In my ViewDidLoad:
if let backgroundMusic = self.setupAudioPlayerWithFile("Kawai Kitsune", type:"mp3") {
self.backgroundMusic = backgroundMusic
}
if backgroundMusic != nil {
if backgroundMusic?.playing == false{
backgroundMusic?.volume = 0.1
backgroundMusic?.play()
print("play")
}
else {
print("playing")
}
}
| b3d99c7d8622ac7875a203c48cb6e6f82bba292f90a04e44b99580b4df7b9eea | ['eb0132d22975436b87f633e42b559551'] | You may want to try this to get a view's frame during an animation:
let currentFrame = myView.layer.presentation()!.frame
That will get you the frame at the time the code runs so if you wanted a record of the frames throughout the animation you may want to use a Timer (previously NSTimer).
In this example the optional is force unwrapped so if you're not sure if it's nil or not you may want to use an if-let statement.
Hope this helps and let me know if you have any other problems.
|
d512c64c614add8727a85d3fd92b7b70bd343d6d46e804a62f59d52b43ec009d | ['eb0281eaa3274e78ba80c8034ec5187f'] | Here is the best solution for you.
You can use Hooks
Step1:
application/config/config.php
$config['enable_hooks'] = TRUE;//enable hook
Step2:
application/config/hooks.php
$is_logged_in= array();
$is_logged_in['class'] = '';
$is_logged_in['function'] = 'is_logged_in';//which function will be executed
$is_logged_in['filename'] = 'is_logged_in.php';//hook file name
$is_logged_in['filepath'] = 'hooks';//path.. default
$is_logged_in['params'] = array();
$hook['post_controller_constructor'][] = $is_logged_in;//here we decare a hook .
//the hook will be executed after CI_Controller construct.
//(also u can execute it at other time , see the CI document)
Step3:
application/hooks/is_logged_in.php //what u decared
<?php
//this function will be called after CI controller construct!
function is_logged_in(){
$ci =& get_instance();//here we get the CI super object
$session = $ci->session->userdata();//get session
if($session['isloggedin']){ //if is logged in = true
$ci->username = 'mike';//do what you want just like in controller.
//but use $ci instead of $this**
}else{
//if not loggedin .do anything you want
redirect('login');//go to login page.
}
}
Step4:application/controller/pages.php
<?php
class pages extends CI_Controller{
function construct ........
function index(){
echo $this->username;//it will output '<PERSON>', what u declared in hook
}
}
Hope it will help u.
| 5e3ee0b93df01c44aee024a1f08fe83461dd1fff1bd1b261b6a46a562a4c518e | ['eb0281eaa3274e78ba80c8034ec5187f'] | the function $this->load->view()
will output a HTML header. so u cannot output header twice.
the correct way is
controller file
public function admin($page = "admin")
{
$data['title'] = "admin";
$data['menu'] = "admin";
$this->load->view('admin/index'.$page,$data);
}
view file admin/index.php
<html>
<?php include '../tpl/header_admin.php' ?>
template context.....
</html>
This is the way of using the template file pieces
|
c347993b820e9d8aeac1ab8aba6bad6a531f9ac0b3240a71edbf45a965a5bd90 | ['eb1ce4d98f3a4aa19eeced564d72ec88'] | Am trying to run react native using react-native run-android but I get the above error. I was having issues getting my detached expo to run on android emulator and I keep getting this error Error running app. Have you installed the app already using Android Studio? Since you are detached you must build manually. Error: Activity not started, unable to resolve Intent { act=android.intent.action.VIEW dat=....
After hours of futile effort i tried running react-native run-android but I keep getting the above error (title). solution online spawnSync ./gradlew EACCES error when running react native project on emulator udara shows its a permission issue and that it can be resolved with
chmod 755 android/gradlew
since am using a windows system i tried
ICACLS "android/gradlew" /grant:r "Administrator:(F)" /C
but I still get the same error. am not really good with icacls so I may be wrong. any assistance is highly appreciated.
My emulator is working perfectly cause i did a adb devices check and its their. I even have the emulator already open on my window
| bb56475dc2de0c54c05296045343a1ab25ac29b986074d74e4832a554e505e84 | ['eb1ce4d98f3a4aa19eeced564d72ec88'] | For the last 24 hours I have been trying to get my expo client to build JavaScript on my device. I have been using expo for some weeks now. And thou it may be difficult to get it running I some how manage to use it for some hours. Usually I can easily connect using tunnel. Recently I was able to 'trick it' to work without internet. But for the last 24 hours I can't get to work using any of the options available... I have scout the Internet for solutions and tried them with no success .
I keep getting type error java.net sockettimeoutexception network timeout error .....1000ms I have had to reset a lot on my system disabled all firewalls. Pause antivirus , reset react native packager hostname, clear cache for both expo and npm etc..
Lastly I tried removing and downloading the expo client app . But the app fails to download. Tried other apps and they work OK..
|
64491ba1425724399114c768670b50d92849aa8e07d56ed186787f2d797eef2d | ['eb2eb17f887448c7b73cd67bea21ebcb'] | I have successfully created a ternary plot with the following code:
data <- read.csv(file, header=TRUE)
ternaryplot(data[,3:5], scale = 100,
pch = 19, cex = 0.4, col = Category,
dimnames = c("Al", "Mg", "Fe + Ti"),
labels = c("outside"),
main = "")
However, I am struggling to create a legend for it. As the package has assigned colours based on the category of the sample I cannot simply write out the entire legend by allocating colours manually.
I have tried a few variations of the following but have encountered the error code:
grid_legend(0.8, 0.9, pch = 19, col = Category, rownames(Category), title = "Categories")
Error in grid_legend(0.8, 0.9, pch = 19, col = Category, rownames(Category), :
pch and labels not the same length
This is the first time I have used the vcd package and would appreciate any help on the subject.
Thanks,
<PERSON>
| 805c6928229d9128d4afb3ac5528a3b9c1854e4c743c5e3fa7d3a1e8c9e60773 | ['eb2eb17f887448c7b73cd67bea21ebcb'] | I am new to using the ggplot2 package and am unfortunately having trouble with the basics. My data set is in a csv comma delimited file which has been working in R using plot functions but doesn't seem to be working in ggplot2. My csv file looks as follows:
Depth Min Max Average Mode
34 2 38 5.64 2
44 2 25 6.27 2
etc....
The code I am using is as follows:
Statsnineteen <- read.csv(file="C:/Users/Holly/Documents/Software Manuals/R
Stuff/Stats_nineteen.csv", header=TRUE, sep=",")
p1 <- ggplot(Max, Depth, data = Statsnineteen)
p1 <- p1 + layer(geom="path") + coord_flip()
It then comes up with the following error message between the two p1 lines:
Error in inherits(mapping, "uneval") : object 'Max' not found
I know it can read the table as when I use:
Statsnineteen <- read.table(file.....)
head(Statsnineteen, n=52)
It brings up my data table.
Don't suppose anyone knows if there is a command I've missed out or if there is something wrong with my code?
Thanks in advance for any help, <PERSON>
|
4884c64b9ffc27b60451e8c948a54a921998343c08a019764d757a187b208d1f | ['eb36bf2ffaa442bf8f51929cdf44b606'] | Actually only mechanical waves need a medium to propagate. Examples of mechanical waves are waves in water and sound waves. Mechanical waves are caused by a disturbance or vibration in matter, whether solid, gas, liquid, or plasma. Medium is the matter the waves are traveling through.
The Electromagnetic waves are completely allowed to travel in a vacuum, that's actually one of their most important characteristics.
| b40706b446b4328fa567244c53c7d7911c15e78082f8f3192cc3c5eeed2e86a4 | ['eb36bf2ffaa442bf8f51929cdf44b606'] |
Do the charges on the one side stop the effects of the electric field of the charges on the other sides of the surface?
Actually, if the charge density is uniform, we consider the whole charge concentrated in the center of the sphere, in such a way that all the outward field lines were created by a single electric charge carrier in the center of the sphere.
Moreover, does a charge effectively "block" the electric field generated by another charge? For example here, does the third charge feel the presence of the first even if there is another element in the middle?
The electric field is a vector. In the spherical symmetric cases -- the one you had in the image -- we can calculate the electric field by $\bf{E} = \frac{kq}{r^{2}}\hat r$ where $\bf E$ is the magnitude of the electric field, $k$ is the Coulomb constant, $q$ is the charge of the generator of the electric field and $r$ is the distance between the generator of the electric field and a determined point in space. Obs.: [r] = meters, and [q] = coulombs, in the I.S.
You can do the calculations of your example by yourself, but what matters is that you can create a situation of three particles and, depending on the values of the $q$ and $r$, the second particle be submitted to a null net electric field, since there will be a vector sum of opposite vectors.
|
9427232d616b2813a9968f8ed9f762c24965858ce591b0bad7eb8fdd62f59302 | ['eb3c180238fa400cb0a0c6e6aafb3a36'] | I would suggest you to reload the tableView in a completionBlock rather than the way you are calling
Swift 3
let say you are getting data through NSURLsession
func getDataFromJson(url: String, parameter: String, completion: @escaping (_ success: [String : AnyObject]) -> Void) {
//@escaping...If a closure is passed as an argument to a function and it is invoked after the function returns, the closure is @escaping.
var request = URLRequest(url: URL(string: url)!)
request.httpMethod = "POST"
let postString = parameter
request.httpBody = postString.data(using: .utf8)
let task = URLSession.shared.dataTask(with: request) { Data, response, error in
guard let data = Data, error == nil else { // check for fundamental networking error
print("error=\(error)")
return
}
if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode != 200 { // check for http errors
print("statusCode should be 200, but is \(httpStatus.statusCode)")
print(response!)
return
}
let responseString = try! JSONSerialization.jsonObject(with: data, options: .allowFragments) as! [String : AnyObject]
completion(responseString)
}
task.resume()
}
Since you are using Alomofire you can change accordingly
getDataFromJson(url: "http://....", parameter: "....", completion: { response in
print(response)
//You are 100% sure that you received your data then go ahead a clear your Array , load the newData then reload the tableView in main thread as you are doing
orders = []
let info = Order(shopname: shopname, shopaddress: shopaddr,
clientName: cleintName,ClientAddress: clientAddres, PerferTime: time,
Cost: subtotal , date : time , Logo : logoString ,id : id)
self.orders.append(info)
DispatchQueue.main.async {
self.tableview.reloadData()
}
})
Completion blocks should solve your problem
| e4b2a453931ed476f65a767c3328ebfa7bda18f7ec3cfcbfabb54723d10d2734 | ['eb3c180238fa400cb0a0c6e6aafb3a36'] | I would suggest a generic solution related to solve similar problems detecting different launch Options (How our App is in Active state (Running))
Swift 2.3
In AppDelegate
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
if let options = launchOptions{
print(options.description)
//These options will give the difference between launching from background or from pressing the back button
if (launchOptions?[UIApplicationLaunchOptionsRemoteNotificationKey] != nil) {
//this indicates the app is launched by pressing Push notifications
}else if (launchOptions?[UIApplicationLaunchOptionsLocalNotificationKey] != nil) {
//This indicates the app is launched on tapping the local notifications
}else if (launchOptions?[UIApplicationLaunchOptionsSourceApplicationKey] != nil){
//This indicates the App launched from a valid source e.g: on tap of Open App from App Store when your App is installed or directly from home screen
}
}
}
Reference:
Apple docs provide all the available launch options which can be detected
https://developer.apple.com/documentation/uikit/uiapplicationdelegate/launch_options_keys
Use the Power of delegate Protocol methods by adding Observers
https://developer.apple.com/documentation/uikit/uiapplicationdelegate
Swift 3 Equivalent:
//adding observer
NotificationCenter.default.addObserver(self,
selector: #selector(applicationDidBecomeActive),
name: .UIApplicationDidBecomeActive,
object: nil)
//removing observer
NotificationCenter.default.removeObserver(self,
name: .UIApplicationDidBecomeActive,
object: nil)
// callback
func applicationDidBecomeActive() {
// handle event
}
Similar Questions in StackOverFlow which my help you out:
Detect when "back to app" is pressed
How to detect user returned to your app in iOS 9 new back link feature?
Detect if the app was launched/opened from a push notification
Checking launchOptions in Swift 3
|
7716ea16766135699f7e0dd95c5fcacf52e4d1dff1c5e49aa78f5cf17f7bbbd2 | ['eb3c19845b5a4bf7a10f86391f1f8dac'] | It's not possible to do animate height and width to auto.
So this is <PERSON> method to allow that to work.
See the changes that i made in your file.
Basically you need to create the method animateAuto and call it when you need to animate.
JQUERY
jQuery.fn.animateAuto = function(prop, speed, callback){
var elem, height, width;
return this.each(function(i, el){
el = jQuery(el),
elem = el.clone().css({"height":"auto","width":"auto"}).appendTo("body");
height = elem.css("height"),
width = elem.css("width"),
elem.remove();
if(prop === "height")
el.animate({"height":height}, speed, callback);
else if(prop === "width")
el.animate({"width":width}, speed, callback);
else if(prop === "both")
el.animate({"width":width,"height":height}, speed, callback);
});
}
usage:
$(".wrapper").on("mouseenter",".tabs",function(){
$(this).stop().animate({
width:"202px",
duration:"fast"
});
}).on("mouseleave",".tabs",function(){
$(".tabs").stop().animateAuto("width", 1000);
});
JsFiddle
http://jsfiddle.net/PMBxT/3/
Hope it solves your problem
| ebaf5a3b64e84980aff2b537fe9ebbedbc271c7d76d0fb75aa8f3cd59628d9d8 | ['eb3c19845b5a4bf7a10f86391f1f8dac'] | You can use:
$.each(this.fooArray, $.proxy(function(i) {
alert(this.fooText);
}, this));
or if you're using backbone with underscore you could do:
$.each(this.fooArray, _.bind(function(i) {
alert(this.fooText);
}, this));
or natively(but don't work in all browsers):
$.each(this.fooArray, function(i) {
alert(this.fooText);
}.bind(this));
hope it solves your problem.
|
911ce88a9d00cee18ab1bf1760105d71be4dd8175de7b39d276228fc67506dac | ['eb41f573b8cf451a9b1ae027738b16e5'] | ¿Estas usando un SO Unix? Segun parece para ciertas distribuciones los nombres de las tablas distinguen mayusculas de minusculas en MySql, y tu SELECT lo haces a 'Piezas' mientras que tu UPDATE lo estas haciendo a 'piezas'
En el siguiente enlace puedes verlo:
https://stackoverflow.com/questions/6134006/are-table-names-in-mysql-case-sensitive
| f073eabd45bb815cc104e6e5aaeefcb362839eaa3a75391e5267f9fa8a2439a9 | ['eb41f573b8cf451a9b1ae027738b16e5'] | Actually djb2 is zero sensitive, as most such simple hash functions, so you can easily break such hashes.
It has a bad bias too many collisions and a bad distribution, it breaks on most smhasher quality tests: See https://github.com/rurban/smhasher/blob/master/doc/bernstein
His cdb database uses it, but I wouldn't use it with public access. |
0a6548b91b9ab7666fca41222368fbbfde5b8b9052c0afd9386f7238114ed8e9 | ['eb5b4601af79488f9cd4e8e77563e42c'] | Make sure you've added these permissions to your android manifest.
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
and make sure you're requesting ACCESS_COARSE_LOCATION if it doesn't do it automatically:
// Handling permissions.
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_COARSE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
// Permission is not granted
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.ACCESS_COARSE_LOCATION)) {
// Not to annoy user.
Toast.makeText(this, "Permission must be granted to use the app.", Toast.LENGTH_SHORT).show();
} else {
// Request permission.
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_COARSE_LOCATION},
REQUEST_PERMISSION_BLUETOOTH);
}
} else {
// Permission has already been granted.
Toast.makeText(this, "Permission already granted.", Toast.LENGTH_SHORT).show();
}
and specify what should happen if the user accept/decline the request:
@Override
public void onRequestPermissionsResult(int requestCode,
@NonNull String permissions[], @NonNull int[] grantResults) {
switch (requestCode) {
case REQUEST_PERMISSION_BLUETOOTH: {
// If request is cancelled, the result arrays are empty.
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this, "Permission granted.", Toast.LENGTH_SHORT).show();
// Permission granted.
} else {
Toast.makeText(this, "Permission must be granted to use the application.", Toast.LENGTH_SHORT).show();
}
}
}
}
| 96661b2e389fe361a4b3291153e5d67543e825f97d8010878bdecee1c2c2a7f3 | ['eb5b4601af79488f9cd4e8e77563e42c'] | Logged in as Test User to post to group in app while in development mode, but failed.
According to this bug report
https://developers.facebook.com/support/bugs/374244166706163/
It works only when I'm an admin of both the app and group.
To request Groups API permission in App review section, I have to reproduce my application's functionalities using a test user.
How am I supposed to do that if my developer account is the only one able to successfully post to group?
|
345b7eaff212bb86616ef3b7fba051ea47c3eb73545ed9c611fb4fde70adf6aa | ['eb5d96177d6447cda632eda70a42094e'] | Нужна формула для проверки вхождения точки на карте в полигон в форме правильного шестиугольника. Центр имеет широту и долготу, каждая точка шестиугольника также имеет широту долготу. Длина сторон 200 метров.
Стороны шестиугольника для примера.
Сторона a [ aX, aY ], [ bX, bY ] - это первая верхняя сторона шестиугольника, а дальше по часовой стрелке
Сторона b [ bX, bY ], [ cX, cY ]
Сторона c [ cX, cY ], [ dX, dY ]
Сторона d [ dX, dY ], [ eX, eY ]
Сторона e [ eX, eY ], [ jX, jY ]
Точки шестиугольника, отсчет первой точки первой стороны
[ aX, aY ]
[ bX, bY ]
[ cX, cY ]
[ dX, dY ]
[ eX, eY ]
[ jX, jY ]
| bfad56d89f3a2bb645705594427caeea5b0682e83eef7616c794a8008160105f | ['eb5d96177d6447cda632eda70a42094e'] | If we let $f_n(x)=\frac{x^2+nx}{n}$ for $x\in R$. I am trying to show that we can make $f_n$ converge uniformly on the interval $[R,-R]$ For any fixed $R\in(0,\infty)$
One way to show uniform convergence is using the M-test.
So I need to find a series M such that $\sum f_n<=M$ and then if the series $\sum M$ converges then $\sum f_n$ must converge.
But how can I find that series $\sum M$ and then apply the M test.
|
fc7c4697826286bfd4b5f5ada80750e692745a452b4fb1677bc472980e5bb915 | ['eb6192fc44af4234b643160690018af2'] | You can add Jackson to your classpath or add dependencies to maven and Spring Mvc convert your list to json. You only need add parameter to @RequestMapping produces="application/json", in your case it look @RequestMapping(value="getMessages", method=RequestMethod.GET, produces="application/json"), also parameter produces unnecessary but recommended.
And you not need any edit in your controller.
| 6ec67a58bb083de986c409bf220e3fe3b1dcbdedd5f2a9f1ca6123458adcabf0 | ['eb6192fc44af4234b643160690018af2'] | I think it can be used for init resources or fields servlet, because servlet init which caused only at a time when the servlet is loaded and unloaded ( this rarely happens ). It add some independence in your code from values parameters and you can change your parameter with out changes in code also if you override init-method your init servlet only one time and not do it everytime when someone send request to your servlet
|
17672ffcd8e3c504a0689932b4a88183cdc86799e14b8486928acfa4aaf15930 | ['eb717eec007844abb1dfea778bda0f29'] | So I have a Gitlab and a Gitlab-CI server running on separate machines. I am trying to authorize CI as an application via OAuth, but when I hit the Authorize button, I get a 502 error. I've confirmed that I'm using the correct app ID and secret for the application I've created for the CI server in Gitlab, and unfortunately, the nginx and unicorn logs for gitlab aren't exactly providing me with much useful information. Has anyone seen this sort of behaviour before?
| 6ee8d2027476192cccbb6fb3a108563c7473813bbf755ce1a875615dc8b874bc | ['eb717eec007844abb1dfea778bda0f29'] | I just upgraded my Gitlab Omnibus install from 7.3 to 7.9.1, and now rather than showing a login page, Gitlab just shows a 500 error page (see below)
I also noticed the following in /var/log/gitlab/gitlab-rails/production.log
Started GET "/" for <IP_ADDRESS> at 2015-03-31 13:36:56 -0400
Processing by DashboardController#show as HTML
PG<IP_ADDRESS>Error: ERROR: relation "identities" does not exist
LINE 5: WHERE a.attrelid = '"identities"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"identities"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
Completed 500 Internal Server Error in 135ms
ActiveRecord<IP_ADDRESS>StatementInvalid (PG<IP_ADDRESS><IP_ADDRESS>regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"identities"'<IP_ADDRESS>regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
Completed 500 Internal Server Error in 135ms
ActiveRecord::StatementInvalid (PG::Error: ERROR: relation "identities" does not exist
LINE 5: WHERE a.attrelid = '"identities"'<IP_ADDRESS>regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"identities"'<IP_ADDRESS>regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
):
app/models/user.rb:425:in `ldap_user?'
app/models/user.rb:463:in `requires_ldap_check?'
app/controllers/application_controller.rb:208:in `ldap_security_check'
I should note that we use LDAP authentication with Gitlab.
|
abe1fa65a0b96108401c7b75330227c004c4fcac7f1fff83c4984fb1744239ac | ['eb9d8095ea7f434182f933850d785e88'] | An easier way I've found is:
Go to your DB > Configuration > Preview Features > Enable Per-document TTL
Go to your collection in DB data explorer, Scale & Settings, and set the time you want the objects to live:
You can specify the TTL for each object when you insert them in DB (this will override the collection TTL established before). You just need to add to your document a field called "ttl" wich is a double with the format: ttl = 3600.0
And that's it, the documents will delete by themselves after an hour. Good luck!
| 01829159bd575a8fb6e5d7117729be1791c0a2b293df9a3d248d9d31249d867d | ['eb9d8095ea7f434182f933850d785e88'] | Finally, I got it working, so here it is if someone needs a Google Cloud Function for deleting firebase data older than an hour ago (this is set by a key with the timestamp, look at my data model) and now you can schedule a crontab to run the HTTPS request every once in a while.
'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const ref = admin.database().ref().child('geofire'); //Path to the child that contains the items you want to delete
const CUT_OFF_TIME = 3600000; //1 Hour
exports.cleanOldFiles = functions.https.onRequest((req, res) => {
const now = Date.now();
const cutoff = now - CUT_OFF_TIME;
const lastHour = '' + cutoff; //Must be String in order to put it inside .orderByKey().endAt()
const query = ref.orderByKey().endAt(lastHour);
return query.once('value').then(snapshot => {
// create a map with all children that need to be removed
const updates = {};
snapshot.forEach(child => {
updates[child.key] = null;
});
// execute all updates in one go and return the result to end the function
return ref.update(updates);
});
});
|
1c888da9ed8a19ed9fea6fa0d610fd0a7a3e94dc5c205c25795e8afa2b6ae287 | ['ebab6f947bae4dc097a5bdd317c83450'] | Is this what you mean?
DECLARE @t TABLE (TransactionID INT)
DECLARE @p TABLE (PostingType CHAR(1), TransactionID INT)
INSERT INTO @t
(TransactionID)
VALUES
(1),
(2),
(3)
INSERT INTO @p
(PostingType, TransactionID)
VALUES
('A', 1),
('B', 1),
('A', 2),
('B', 3)
SELECT t.TransactionID FROM @t t
WHERE
EXISTS
(
SELECT 1 FROM @p p
PIVOT
(
COUNT(p.PostingType)
FOR p.PostingType IN ([A], [B])
) sq
WHERE
(
([A] = 0 AND [B] > 0) --Postingtype A does not exist then return postingtype B
OR ([A] > 0 AND [B] = 0) --If postingtype A exists only return postingtype A
)
AND sq.TransactionID = t.TransactionID
)
| 244e5065f8a5e85836ab76560e6e16980763134604218d1a2156db1fb0d34405 | ['ebab6f947bae4dc097a5bdd317c83450'] | As of this morning Custom Tabs are no longer displayed to guests (tested from Web App). Yesterday it was still working.
I see that administration of teams has moved to a new admin panel, but I do not see a setting that reflects allowing guest users to access tabs.
I've tried readding the Custom Tab but that does not work.
|
af8d00362beaecd5a74dfa13c0fe5a033cfdaa393d1cc14e1d72fde87afccab2 | ['ebad909213d544019d9e9d05059004c8'] | it's not advertising, it's from me tracking what my car is saying it's getting, as in I looked at was it was getting when it was using brand a and then what it was getting when it was filled with brand b, then calculated the difference and I did reset the tracker in the car in between fill ups. | 4399bb39f6409f837efe8153666aa2b48bf74b4ecce146cc544a764db46d7350 | ['ebad909213d544019d9e9d05059004c8'] | I was learning today about 8051 and I encountered a point which said microntroller generally costs less than a microprocessor.
I didn't understood why is it so since microcontrollers have RAM, ROM, internal oscillators, ADC convertors, comparators and so on on a single chip but microprocessors dont.
I also know that microprocessors have a bigger ALU part compared to microcontrollers but can this only reason increase the cost of microprocessor?
|
aca9b4b4153ee1a0b0014ad57f1919a6862306c6516b1b7c1e2b8fb7578db6c7 | ['ebadad7c2ee84ebd9b7e360099e860ed'] | I think this issue is caused by an underlying process on the remote host. For a similar issue faced by me while connecting to remote host (running Debian OS) using mstsc program from my Windows 7, I used the following steps for resolution:
Login to the remote host's terminal using putty
Execute the following command on the remote host
pskill -u -9 #kills user processes
The established connection with the remote host breaks after successful excution of this command
Login again to the remote host using mstsc / GUI. Your desktop should be back.
| 474cb5914068ee7a15fe76eff3f630f5fa77a35a3642f9d6e076f658909810e1 | ['ebadad7c2ee84ebd9b7e360099e860ed'] | uhm, answering me again, the solution was actually quite trivial. it's not possible, as far as i know, to pass a parameter to the function my_excerpt_length() (unless you want to modify the core code of wordpress), but it is possible to use a global variable. so, you can add something like this to your functions.php file:
function my_excerpt_length() {
global $myExcerptLength;
if ($myExcerptLength) {
return $myExcerptLength;
} else {
return 80; //default value
}
}
add_filter('excerpt_length', 'my_excerpt_length');
And then, before calling the excerpt within the loop, you specify a value for $myExcerptLength (don't forget to set it back to 0 if you want to have the default value for the rest of your posts):
<?php
$myExcerptLength=35;
echo get_the_excerpt();
$myExcerptLength=0;
?>
|
79b44a6202f6070beb517c153f52636f9faeddd4566f94ecf9e8d1c3f5224465 | ['ebae33e192ea473f8508faf5fc5fc882'] | I've been scratching my head over this for half the day now. I am trying to secure the application to prevent any URL tampering, so when i stick a very long sting into the form action's URL parameter, it gets trapped and handled locally just find. But, when i upload it to the server, i get the following error "The data area passed to a system call is too small". Both machines are on IIS 6.
Thanks!
| 5f34aee07af8760cb0970ff037977cf5e0c8b459bbd85f0ec645f35b5596cb2c | ['ebae33e192ea473f8508faf5fc5fc882'] | I am writing Tetris in JavaScript as practice, and i am somewhat confused by the array notation that i am using.
Here's the array that i have that stores all my pieces.
var pieces = [[[1,1],
[1,1]],
[[1,0],
[1,0],
[1,1]],
[[0,1],
[0,1],
[1,1]],
[[0,1,0],
[1,1,1]],
[[1,0],
[1,1],
[0,1]],
[[0,1],
[1,1],
[1,0]]];
What is this notation called? How is this difference from just saying "new array()"?
Thank you!
|
b930a86ad925693ebcdfa37c399a92769328d3d8935d53847a4a997b179ef1ba | ['ebbf9832be1f459fb3b2fe465f227e6f'] | I didn't find any documentation for the karma widget either, despite much googling around.
It seems that you have looked into the script, but I'll nevertheless document some findings here.
Looking in the k.js file that is generated you can see that you specify the sites to show in the widget by using the query parameters t and u:
http://karma.duckduckgo.com/k.js?t=1,5&u=Evgeny,evgenyr
This means for the site identified by 1 the username is <PERSON> and for the site with id 5 the username is <PERSON>. If you look into the script you can see that it is generated on the server side and it has the karma points retrieved already in the script.
The identifiers are as follows (straight from the script @ 2012-10-09):
Id Site
--------------------
1 Hacker News
2 reddit
3 digg
4 Mixx
5 LinkedIn
6 Twitter
7 StumbleUpon
8 delicious
9 YouTube
A Dailymotion
B Plurk
C identi.ca
D Stack Overflow
E MySpace
F GitHub
G Facebook
From looking at the code, you can also customize the look'n'feel of the widget by embedding parameters (starting ddg_k_) as javascript code to your site as you have done. The parameters are almost self-explanatory.
The script also needs an element with the id of ddg_k where it places the widget.
As for why the values are not updated since adding the widget; I can only come up with a educated guess that there's some caching going on. At least here the last message mentions some delays. Also there's some mention about caching issues on the duckduckgo forum. It might also be because the server-side component that retrieves the points is out of date regarding a site.
There's certainly very scarce information on this topic. :-)
| 22f7166911633de1f90b0f5f061aeb2eb2b1703bdd89a8c988600fff8273554a | ['ebbf9832be1f459fb3b2fe465f227e6f'] | @Harry согласен, в таком случае имеется в виду что мы всегда можем повернуть их так, чтобы они были расположены слева и справа. То есть если друг под другом то надо найти левую и правую касательные, а не верхнюю и нижнюю. Друг в друге тоже не могут быть. Сейчас обновлю вопрос |
459d5573abc7612e9638bfd94a4edd81e474d986c175f91cd588839db17db8aa | ['ebc327d94b41465eaa37bdb591cd0395'] | I have a page in which I enable, and make the button visible using JQuery. This is what I am using:
//disable save until validated
$("#btnSave").attr("disabled", true);
Once the validation of a component is completed, I enable the save button:
$("#btnSave").attr("disabled", false);
Problem: It works find with Chrome, FF, IE8+, but does not work with IE7 and below (surprised :O ). Is there any hack for this or a workaround this issue.
| e94071ba8f93d96592c88dc3f6092ab771adeec4873708f8d175c640e2ee8d04 | ['ebc327d94b41465eaa37bdb591cd0395'] | I am looking for a way to assign attributes to a class object after executing enumerate on html string. Basically, this is what I have:
for j, td in enumerate(tr.select('td')):
print(j, td.text)
This outputs:
0 UNITY
1 Unity Foods Limited
2 13.29
3 13.82
4 0.53
5 3.99%
6 0.12%
7 1.81
8 12,472,000
9 163
10 7,519
I want to assign these values to all the params in this following class:
class Product:
def __init__(self,
symbol,
name,
ldcp,
current,
change,
change_percent,
index_wt,
index_point,
volume,
free_float,
market_cap):
self.symbol = symbol
self.name = name
self.ldcp = ldcp
self.current = current
self.change = change
self.change_percent = change_percent
self.index_wt = index_wt
self.index_point = index_point
self.volume = volume
self.free_float = free_float
self.market_cap = market_cap
Is there any "pythonic" way to address this problem?
|
aa9fc71f184ac1578c31cca233d045fbd444e159688c5095a5c1a4d24220eb57 | ['ebcf5c2206e044b8b299e830fb575877'] | I could access my raid and backup my files!!
First I removed the spare device. Then I checked the other devices. There were two devices with bad sectors and I knew that the raid will crash again while resyncing when it wants to read or write to bad sectors.
So I decided to clear the raid and build up a new degraded raid that is not syncing and still has access to all previous data. I cleared all superblocks and created the raid leaving out one damaged device with
mdadm --stop /dev/md127 (or /dev/md0)
mdadm --zero-superblock /dev/sd[efgh]1
mdadm --create /dev/md127 --level=5 --raid-devices=4 --assume-clean /dev/sde1 /dev/sdf1 /dev/sdg1 missing
Important is the original order of the devices for the original raid and to create the new raid in the same order as well as to use the parameter --assume-clean!
You can get the original order with
mdadm --examine /dev/sd[efghi]1
Have a look at Device Role.
After re-creating the raid using assume-clean I could mount md127 and access all data directly without doing anything else.
| 1e1428cda7ed640eea8fc6551ebf46071b787895781ce93d476bf36048cbffad | ['ebcf5c2206e044b8b299e830fb575877'] | I'd like to build a bar graph in excel. The thing i'm having issues with is the formatting of the labels on the datapoints. I'd like the labels to pull from 2 datasets. The bar would be drawn using the first data point say "66%" but i'd like the label to show the percent and the count, something like "66% (14)"
Is this possible?
|
587a67164bf5b81b12ac79227dd9e1dae574d5038e57af0c57dfc63aa9eb54e5 | ['ebd15f6ad5b14b3685741fade2e2b750'] | <?php
try{
include("dbconnectie.php");
$query = $db->prepare("SELECT * FROM shop WHERE id_u = :id");
$query->bindParam("id", $_SESSION['id_u']);
$query->execute();
$result = $query->fetchALL(PDO<IP_ADDRESS>FETCH_ASSOC);
echo "<table>";
foreach($result as &$data) {
echo "<tr>";
$img = $data['img_url'];
echo "<td>" . $data["brand"] . "</td>";
echo "<td>" . $data["model"] . "</td>";
echo "<td> Condition: " . $data["cond"] . "/100 </td>";
echo "<td> Prijs: $ " . number_format($data["price"],2,",",".") . "</td>";
echo "<td> <img src='$img' width='400' height='300' ></img> </td>";
echo "<td>" . "<form method="post" action"">" .
"<input type="submit" name="delete" value="$data['id_img']">" . "</form>" . "</td>";
echo "</tr>";
}
echo "</table>";
} catch(PDOException $e) {
die("Error!: " . $e->getMessage());
}
?>
<html>
<body>
</body>
</html>
on line 17 and line 18 i'm trying to make a button for every time it loops so that i can delete those posts out of my database, but i'm unsure on how to make it loop the button making because it doesn't work how i wrote it.
| 754edded8a65444d471107e1d866ee7fa2ad59e67ec626c4048c312c8d87e648 | ['ebd15f6ad5b14b3685741fade2e2b750'] | <?php
session_start();
include ("dbconnectie.php");
if(isset($_SESSION['on'])) {
header("location:homepage.php"); }
if(isset($_POST['login'])) {
$username = $_POST['username'];
$password = sha1($_POST['password']);
$query = $db->prepare("SELECT * FROM account
WHERE username = :user
AND password = :pass");
$query->bindParam("user", $username);
$query->bindParam("pass", $password);
$query->execute();
$result = $query->fetch(PDO<IP_ADDRESS>FETCH_ASSOC);
$id1 = $result['id_u'];
if($query->rowCount() == 1) {
$_SESSION['on'] = $username;
$_SESSION['id_u'] = $id1;
//header('location: homepage.php');
} else {
echo "The username and password do not match";
}
echo "<br>";
}
?>
<html>
<head>
<title>L O G I N</title>
<link rel="shortcut icon" href="images/jfk.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="css/signin.css">
<link rel="stylesheet" type="text/css" href="css/snackbar.css">
</head>
<header>
<?php
include("#nav.php");
?>
</header>
<form class="modal-content" method="post" action="">
<div class="container">
<h1>I N L O G G E N</h1>
<hr>
<label>G E B R U I K E R S N A A M</label>
<input type="text" name="username" placeholder="Gebruikersnaam Invullen"><br>
<label>P A S S W O R D</label>
<input type="password" name="password" placeholder="Password Invullen"><br>
<button type="submit" class="submit" name="login" value"login" onclick="myFunction()">INLOGGEN</button>
<div id="snackbar">U bent Ingelogd.</div>
</div>
<script>
function myFunction() {
// Get the snackbar DIV
var x = document.getElementById("snackbar");
// Add the "show" class to DIV
x.className = "show";
// After 3 seconds, remove the show class from DIV
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
window.location.href = "homepage.php";
}
//window.location.assign("homepage.php");
</script>
</form>
</html>
All the way at the bottom inside the HTML script, I have window.location.assign to try and redirect after logging and showing the snackbar, but in stead of that it just adds a white bar at the top and doesn't redirect. What I want it to do is after clicking log in, it runs that script. Which does a little pop up for 3 seconds and then redirect to the homepage.
|
cb332a01e647c8a90ca3d9bb9ced92e4e7a0c94ab38f09dcf109d690c1ec35a2 | ['ebd8e3bbb82b49e6a1468105f5af9180'] | Problem Statement:
Currently we are using AD B2C Reset Password Flow for User Registration and Forgot Password in our
application using custom policies and custom html templates. We are also applying custom CSS and
JavaScript. We want to simplify user registration process using AD B2C custom policies
Actual Requirement:
We would like to simply the flow for better user experience as below
Step1: We want to hide the Continue Button
CustomUI
CustomUI-otpVerification
We would want to completely skip this page.
CustomUI-otpVerified
We would like to show user initial text that describes password requirements as below
“Password requires at least 8 characters. Password must contain three of the following: At least
1 upper case, 1 lower case, 1 number and 1 special character”.
We would also like to have all the errors display at one place instead of multiple places.
Limitations:
We tried applying custom JavaScript and CSS injected in our custom html template to achieve
for the things mentioned above. But had no success.
a. Some controls were common across multiple steps which were causing problems in
different edge cases during development when applying some custom JavaScript.
b. Since most of the main controls and form request were not in control in AD B2C, we
were unable to do certain actions like programmatic click etc.,
We thought of updating AD B2C custom policies to achieve mentioned above. But we have not
found any documentation about them.
Preferred Solution:
Ideal solution we would be expecting is to update the AD B2C custom policies to achieve the
desired behavior.
| 4375d0f253e0fc04c9f7cb588e6f21e1169b6a32d776bb6c2495c07f1c50afc4 | ['ebd8e3bbb82b49e6a1468105f5af9180'] | I am an engineer from the Azure B2C support team and I have a customer with the following concern: Is it possible to use an office phone with phone extension on the MFA settings for either user flow or custom policy? Is this something we can modify? All I get is how to enable and disable it.
Thanks in advance.
|
e636b03e57a630cefb9bcaa3ccf9d64146905ea44297f9b00662d3165e9a578a | ['ebe8eca8126d4f319f7b6b086d618a78'] | I have problem with reopen dynamiccaly created fancybox. Firstly i invoke AJAX request and get informations about images. Next i create and preload images in jQuery and after success preload i create instance of fancybox.
I close fancybox and when i try to reopen this with the same action, its open for little moment [0.5 sec] and immediately close [its perform event afterClose one or more times].
$.ajax({
'url' : '<?= Includer<IP_ADDRESS>getBase().'/companies/'.Yii<IP_ADDRESS>$app->request->getQueryParam('id').'/invoices/' ?>' + invoiceId,
'success' : function(data) {
var invoiceObject = jQuery.parseJSON(data);
$('#invoice-thumbnail-list').empty();
var imagesPreloadCounter = 0;
var imagesExpectedCount = Object.keys(invoiceObject.images).length;
var i = 0;
for (var index in invoiceObject.images) {
i++;
url = invoiceObject.images[index].url;
big_url = invoiceObject.images[index].big_url;
a = $('<a>').addClass('invoice-thumbnail').addClass("fancybox-thumb").attr('rel', 'gallery').attr('title', prepareInvoiceData(invoiceObject));
image = $('<img>').load(function() {
imagesPreloadCounter += 1;
if (imagesPreloadCounter == imagesExpectedCount) {
console.info('loaded');
$('div#invoice-thumbnail-list a.invoice-thumbnail').fancybox({
'padding' : 20,
'width' : 425,
'height' : 600,
afterClose : function() {
window.location.reload();
return true;
},
prevEffect : 'none',
nextEffect : 'none',
closeClick : true,
'arrows' : false,
'nextClick' : false,
afterLoad : function (current, previous) {
console.log('afterLoad');
if (current && previous) {
$('.zoomContainer').remove();
current_index = current.index + 1;
$("#invoice_thumb_"+current_index).elevateZoom({
'easign' : true,
'zoomType' : "inner",
'cursor' : "crosshair"
});
}
return true;
},
loop : false,
'helpers' : {
'overlay' : {
'css' : {
'background' : 'rgba(58, 42, 45, 0.7)'
}
},
thumbs : {
width: 50,
height: 50
}
}
});
//$.fancybox.open();
$('.fancybox-thumb').eq(0).trigger('click');
$("#invoice_thumb_1").elevateZoom({
'easign' : true,
'zoomType' : "inner",
'cursor' : "crosshair"
});
}
}).attr('src', url)
.attr('height', '100%')
.attr('width', '100%')
.attr('data-zoom-image', big_url)
.attr('alt', '')
.attr('id', 'invoice_thumb_'+i);
$(a).append(image);
$('#invoice-thumbnail-list').append(a);
}
}
});
Above is fragment of code with this functionality. I dont know why fancybox trigger a lot of afterLoad images.
| 024655d314d0f106395174c7c49e8158fad7970b9955097822f7bea6e8ab41a9 | ['ebe8eca8126d4f319f7b6b086d618a78'] | I need to pass to iframe url, that require basic auth.
Method http://username:<EMAIL_ADDRESS> is deprecated and workd on Google Chrome, but not on IE.
I tried method with reversed proxy, but in this case i need to use original url (relative paths). Url is to external website which has not configured CORS.
Is any solution for this problem?
Ultimately i can write to programists from destination website to configure CORS, if only solution is use javascript and AJAX request.
|
f20be19f432f17751795111638c65a7298c19f1c0de8f3720ce868f818d08a4b | ['ebf89906b1b54ec099b6ca14b643815b'] | When I run my query, it prints multiple execution times instead of just one. I only want one so what should I use instead of SET STATISTICS?
SET STATISTICS TIME ON
DECLARE @firstNum INT, @secondNum INT, @thirdNum INT, @evenSum INT
SET @firstNum = 1
SET @secondNum = 2
set @thirdNum = 2
SET @evenSum = 2
WHILE (@thirdNum <= 4000000)
BEGIN
SET @thirdNum = @firstNum + @secondNum
SET @firstNum = @secondNum
SET @secondNum = @thirdNum
IF (@thirdNum % 2) = 0
SET @evenSum += @thirdNum
END
PRINT 'Answer = ' + CONVERT(VARCHAR, @evenSum)
SET STATISTICS TIME OFF
It prints this like a hundred times:
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.
| afe0faab22f1fbe0ced158498e90718f83f6730d7b105790c78e2baffd373dba | ['ebf89906b1b54ec099b6ca14b643815b'] | What I mean to ask is if I have to choose a random number of elements(say 3) without replacement from a set(for example {1,2,3,4,5,6,7}) with a probability distribution generated by running a pseudo random number generator number of times equal to the size of the set and normalized to summation of 1.
Is this equivalent to choosing a random number of elements from the same set without replacement?
Are their any biases that happen?
|
e87b192b6c31f80ad1703b45ce12bbc8dd00c93dbe778e046e329d9025ea661c | ['ebff52d7936043b887ad738a287cdceb'] | I'm new to opencv library and every time i try to compile This code
#include "opencv2/core.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgcodecs.hpp"
using namespace cv;
using namespace std;
int main()
{
Mat img;
img = imread("lena.jpg");
imshow("Original Image", img);
waitKey();
}
I get This error undefined reference to `__atomic_fetch_add_4
This code is copied from a tutorial and It's was working with its writer so the problem is definitely with me
I looked for a solution for this problem to much and I did not found any working solution, I do not even no what is the cause of the problem
I'm using Code<IP_ADDRESS>Blocks IDE
Thanks,
| a185a5d7eaee92c724ec90b0411e70f9c6ead67093db119b3972218aeeeb6836 | ['ebff52d7936043b887ad738a287cdceb'] | Since x and y are not initialized, and std<IP_ADDRESS>cin>> x >> y; has failed because it expects an int and got a char, the behavior is undefined. It highly depends on the compiler. Your code on other compilers may give 0 0 0 as an output since the compiler has initialized x and y for you. On other compilers may give different value other than 4196208
Try this code,
#include <iostream>
using namespace std;
int main()
{
int x=2,y=2;
cin>>x>>y;
int z=x+y;
cout<<x<<" "<<y<<" "<<z;
return 0;
}
The output gonna be 2 2 4. Because x and y are initialized and the exception thrown by std<IP_ADDRESS>cin will be ignored and the execution will continue to evaluate the sum.
Note that std<IP_ADDRESS>cin is an std<IP_ADDRESS>basic_istream object. The >> operator is overloaded to return a reference to the stream itself that could be evaluated as a boolean. So you could write some code like this
if(!(std<IP_ADDRESS>cin>>x>>y)) {
//do something
}
|
7e24fe41c390164461aa38e54ffc39f2fc4a590dcb7f52228d4dd685dfb60e5b | ['ec008678365349659d78064cb3a81164'] | I installed Ubuntu 16.04 LTS and chose the option to remove all and set an encrypted LVM(I have a backup of all my data).
I have 1 SSD(/dev/sda) and 1 HDD(/dev/sdb).
What the installer did:
It set LVM for /dev/sda and that's all, it didn't touch /dev/sdb.
What I try to do and can't find info about(there is info on what I try to do but not with LVM + encryption - at least from what I could find):
- Remove encryption from the root /(that's not that important, but I don't need security for that data, I would like performance)
- Set /home, /var and /tmp to be on the encrypted HDD(/dev/sdb) - this is the main issue
- Remove swap from the SSD
Relevant fdisk -l output:
Disk /dev/sda: 119,2 GiB, 128035676160 bytes, 250069680 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xb607a342
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 1001470 250068991 249067522 118,8G 5 Extended
/dev/sda5 1001472 250068991 249067520 118,8G 83 Linux
Disk /dev/sdb: 698,7 GiB, 750156374016 bytes, 1465149168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 3E77BD28-907B-4CDD-B5A9-5886A8E3CF74
Device Start End Sectors Size Type
/dev/sdb1 2048 1465149134 1465147087 698,7G Linux LVM
Disk /dev/mapper/sda5_crypt: 118,8 GiB, 127520473088 bytes, 249063424 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/ubuntu--vg-root: 110,8 GiB, 119000793088 bytes, 232423424 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/ubuntu--vg-swap_1: 7,9 GiB, <PHONE_NUMBER> bytes, 16588800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Any guru out there? :)
| 9a28651d9cbd8d962b569b55b058b6e16d3522187c4565f5c4c39250e692cc15 | ['ec008678365349659d78064cb3a81164'] | I see your point. A security professional is less likely to roll his own, and if he does, he has a better chance of doing it right than an amateur. My question is more about the amateurs or the inexperienced, and it seems that if people are pointed towards established standards, maybe they'll get something out of it apart from the immediate utilitarian benefit. |
60e327606062bf4899d94f61c5b8e1a3be126e45311e24ff4cf17640c10a1e20 | ['ec015991e9f442e6adfdb314cc0b5dbc'] | I just wanted to add to <PERSON>'s answer. Note that this is identical to his answer except that I changed copy(new_arr[i]) to copy(arr[i]), and new_arr.length to arr.length.
function copy(arr){
var new_arr = arr.slice(0);
for(var i = arr.length; i--;)
if(new_arr[i] instanceof Array)
new_arr[i] = copy(arr[i]);
return new_arr;
}
The reason copy(new_arr[i]) worked is because the .slice copied over what arr[i] was pointing at, making them equal.
Also, while <PERSON>'s answer works for all cases, if by chance each member of each dimension of the multi-dimensional array is either an array or a non-array you can make it more efficient by only slicing non-array dimensions.
I mean what is the point of copying over an array of pointers that will simply be overwritten by the following recursion?
function copy(arr){
if(arr[0] instanceof Array){
var new_arr = new Array(arr.length);
for(var i = arr.length; i--;)
new_arr[i] = copy(arr[i]);
}
else{var new_arr = arr.slice(0);}
return new_arr;
}
| 6f4554cc1451626ef9d598a0c91a664a5341c94881c34fdf179aa5c682e36617 | ['ec015991e9f442e6adfdb314cc0b5dbc'] | Usually when I make a change in a source code file the server automatically updates. Though occasionally it does not, even if I reload the page, or even close the tab and load fresh from a new blank browser tab. I have to restart the server to finally see the change. I found this out upon changing a console.log message.
Is there a way to ensure that the server is using all of the latest source files without having to restart the server? (ya as I already mentioned usually it does this automatically, but at times it does not.)
|
3a54b901a98b4042419ba275792aefeb201ea398d427fc4dfe4eedb6bc6d3d00 | ['ec25bb6aaf2844ed8e8849ee08bfc63a'] | I have a list where the li images are floating left and arrange themselves in different numbers of rows depending on window size (using media queries and different img sizes). The vertical spacing between the elements is done by using a bottom margin. However, the list items that wind up on the bottom row don't need a bottom margin on them: it leaves too much space above the footer. I figured out a (probably inefficient) way using JQuery to get rid of the bottom margin on the items on the bottom row:
bottomMargin();
window.onresize = bottomMargin;
function numberOfRows () {
var noOfRows = 0;
$('#gallery ul li').each(function() {
if($(this).prev().length > 0) {
if($(this).position().top != $(this).prev().position().top)
noOfRows++;
}
else
noOfRows++;
});
return noOfRows;
}
function whichRow() {
var thisRow = 0;
$('#gallery ul li').each(function() {
if($(this).prev().length > 0) {
if($(this).position().top == $(this).prev().position().top) {
$(this).data('row', thisRow);
}
else {
thisRow++;
$(this).data('row', thisRow);
}
}
else {
thisRow++;
$(this).data('row', thisRow);
}
});
}
function bottomMargin() {
whichRow();
var totalRows = numberOfRows();
$('#gallery ul li').each(function () {
if ($(this).data('row') == totalRows)
$(this).css('margin-bottom', '0%');
else
$(this).css('margin-bottom', '');
});
}
This will work the majority of the time. However, if I resize more than one media query away from where the page loaded, it won't alter the margins on the initial window resize. I have to resize again very slightly before it gets rid of that pesky bottom margin. Why should it take two resizes?
| a844893afa06e8c8ad7fbe9ecdd45ecfea7bc00970d064b9ecdb751b0d7a5725 | ['ec25bb6aaf2844ed8e8849ee08bfc63a'] | I'm working on a sales gallery where the user clicks on a image, and a popout box fades in front of the page. The box includes product details, order information, and a stylized exit button to close the box and return to the gallery. The user can also return to the gallery by clicking outside the box. However, when the box is open, I want all links behind the window (nav menu, etc) except the exit button to be disabled. They should be enabled again once the user closes the box. I've tried playing around with things like
$('a:not(a.popout)').removeAttr('href');
and
$('a').attr('href', '');
to no avail. The only thing these manage to do is shut down every link on the page for good and of course there's no way to re-enable them again once I've totally removed the href attribute. Anyone else ever tried to do this? Maybe I'm doing it he hard way. Running out of ideas. Thanks!
|
b695f97d3bed59ba5d04446b730a28abf34c5c80312803c43c3ccde656b98852 | ['ec26c2a5c64f45a0b231dd352c2374d5'] | Tested... And this will work, but please read below...
CREATE TABLE Bank_Branchs(
Branch_ID NUMBER(15) NOT NULL,
Branch_Name VARCHAR2(15),
Country VARCHAR2(35),
City VARCHAR2(35),
Phone VARCHAR2(15),
Manager_ID NUMBER(7) NOT NULL,
PRIMARY KEY (Branch_ID,Manager_ID)
);
CREATE TABLE Departments(
Dept_ID CHAR(3) NOT NULL,
Dept_Name VARCHAR2(25),
Head_of_Dept NUMBER(7),
PRIMARY KEY(Dept_ID)
);
CREATE TABLE Job_Titles(
Title_ID CHAR(3)NOT NULL,
Title_Name VARCHAR2(25),
Title_Desc VARCHAR2(250),
PRIMARY KEY(Title_ID)
);
CREATE TABLE Employees
(Emp_ID NUMBER(7) NOT NULL,
Branch_ID NUMBER(15) NOT NULL,
Title_ID CHAR(3),
Department_ID CHAR(3),
Manager_ID NUMBER(7),
Salary NUMBER(9),
Hourly_Rate NUMBER(9),
PRIMARY KEY(Emp_ID),
FOREIGN KEY(Branch_ID, Manager_ID) REFERENCES Bank_Branchs(Branch_ID, Manager_ID),
FOREIGN KEY(Title_ID) REFERENCES Job_Titles (Title_ID),
FOREIGN KEY(Department_ID) REFERENCES Departments (Dept_ID)
);
It seems like a manager_id would correspond to a employee_id...
It also seems like their may be more than one manager for an individual bank branch..
Bascically, i think manager_id should be removed from bank_branches and this should be created instead:
create table bank_branch_managers(
branch_id number(14),
manager_id number(7),
effective_date date,
activity_date date,
PRIMARY KEY (branch_id, manager_id),
FOREIGN KEY (branch_id) REFERENCES Bank_Branches(Brand_id),
FOREIGN KEY (manager_id) REFERENCED Employees( Emp_id)
);
But you'd need to adjust the setup of "Employees", probably adding a table for managers as well..
| acbd7b337521e3ce0f605798b563aea0bc28f27d631a57d70f28223ca24755b5 | ['ec26c2a5c64f45a0b231dd352c2374d5'] | Stumbled on this question looking for hints to counting edges with gonum/graph as well. I haven't found a ton of resources other than digging through the API docs.
Think I found the right way to count edges for single nodes.. Maybe!
for _, node := range graph.NodesOf(g.Nodes()) {
toNodes := g.From(node.ID()) // returns graph.Nodes
nodeArray := graph.NodesOf( toNodes ) // returns []graph.Node
edgeCount := len(nodeArray)
// - or -
edgeCount := len(graph.NodesOf( g.From(node.ID()) ))
// do work with edge count
}
Given a known node and all the nodes you can get to from there, you can count (ex: len(graph.NodesOf(g.From(node.ID()))) the number of edges!
To count all of the edges:
totalEdges := len(graph.EdgesOf(g.Edges()))
|
329103c21c5b4a9c2af8f7aed266a82260c589625ac4ba47f9bad1149d0bf24e | ['ec2e773eab1b4e959c08ce5ca1dc37c7'] | Looking back at this question now, I'd say that C# extension methods completely destroy the need for utility classes. But not all languages have such an in-genius construct.
You also have JavaScript, where you can just add a new function right to the existing object.
But I'm not sure there really is an elegant way to solve this problem in an older language like C++...
Good OO code is kinda hard to write, and is hard to find since writing Good OO requires a lot more time/knowledge than writing decent functional code.
And when you're on a budget, your boss isn't always happy to see you've spent the whole day writing a bunch of classes...
| 3adf7b7627efb3382ce60126b6a56c2687b3dc46fe86ad0e75932f48504157e3 | ['ec2e773eab1b4e959c08ce5ca1dc37c7'] | A conventional grails 3 plugin is different than a plugin within a multi-project. It doesn't seem to be designed to compile a plugin such as grails scaffolding with custom commands.
For this reason, you should package the plugin manually using:
grails package-plugin
grails install
Now in the build.gradle, add this line to dependencies:
compile "<plugin-group>:<plugin-name>:<plugin-version>
Subsituting the appropriate information within the brackets <>.
You can find the plugin-group in the plugin's build.gradle
group "org.grails.plugins"
plugin-name you specified in the grails create-plugin command
grails create-plugin plugin-name
plugin-version is also found in the plugin's build.gradle
version "0.1"
|
30c6d30cb5eaaefadde3404bdb1449aeb1cb6ede6c47417a459f455d170a488b | ['ec2f4128640e4021981ec1b3a694964a'] | you can try this approach in pyspark
from pyspark.sql import SparkSession
from pyspark.sql import functions as F
spark = SparkSession.builder \
.appName('practice')\
.getOrCreate()
sc= spark.sparkContext
df = sc.parallelize([
("RR Industries",None), ("RR Industries", "RR Industries")]).toDF(["Name1",
"Name2"])
df.withColumn("Name3", F.concat_ws("", F.col("Name1"),
F.col("Name2"))).show(truncate=False)
+-------------+-------------+--------------------------+
|Name1 |Name2 |Name3 |
+-------------+-------------+--------------------------+
|RR Industries|null |RR Industries |
|RR Industries|RR Industries|RR IndustriesRR Industries|
+-------------+-------------+--------------------------+
| 69a332ca3aa256ca45756785a716d9d93227b9e9aa957ef27c241505dfb924c8 | ['ec2f4128640e4021981ec1b3a694964a'] | check this out. you can use groupby and pivot. Please note i renamed name column because it was ambiguous to the dataframe once the name values are pivoted
df.show()
# +------------+-----+
# | name|value|
# +------------+-----+
# | Name| str|
# |lastActivity| date|
# | id| str|
# +------------+-----+
df1 = df.withColumnRenamed("name", "name_val").groupBy("name_val").pivot("name_val").agg(F.first("value"))
df1.show()
# +------------+----+----+------------+
# | name_val|Name| id|lastActivity|
# +------------+----+----+------------+
# | Name| str|null| null|
# | id|null| str| null|
# |lastActivity|null|null| date|
# +------------+----+----+------------+
df1.select(*[F.first(column,ignorenulls=True).alias(column) for column in df1.columns if column not in 'name_val']).show()
#
# +----+---+------------+
# |Name| id|lastActivity|
# +----+---+------------+
# | str|str| date|
# +----+---+------------+
|
22d63ad1a134e3b1ed0e5e69ca929b3db6e633ff2908d755dd04c9c37ba4861c | ['ec310b8b82ca43c992050681a87a7d58'] | I am trying to call an external program from within my C program. I understand that calling system() is a bad habit. I've been reading up on how to use execl() or execv() to replace system(), but due to my limited brain capacity, I would like to ask for some examples and guidance.
If I was going to run
int return_val = system("/usr/bin/someprogram arg1 arg2 arg3");
then is this what I should do instead?
if ((pid = `fork()`) == -1)
perror("fork error");
else if (pid == 0) {
execl("/usr/bin/someprogram", "arg1", "arg2", "arg3", NULL);
perror("Return not expected: execl error");
}
I found a similar question on StackOverflow about replacing system() with execl(), but the answer (3 votes) did not talk about fork().
How to use execl as replacement for system
Do I need fork() if I am waiting for the child process to finish so my own program can continue?
I know there is also execv() but my limited-capacity brain would prefer execl() unless someone tells me there is a disadvantage to that. Most examples on the web use execv instead of execl, probably because when I search for execl, Google keeps telling me about MS Excel functions.
I'll describe my use case but, in case I need it for other circumstances, would prefer general answers to my question over answers specific to my circumstances like, "Why are you even using $PROGRAM1 ? You should download $PROGRAM2 instead!"
I'm cobbling together a PyQt application for my child's Kubuntu system to limit Internet access to certain sites (youtube) to a certain number of hours per day. He can voluntarily turn off his own Internet access to save up access time for later; and when he turns it back on, my app will set the iptables rules according to how much time is left. Ideally I'd call "iptables" from within my Python app, but iptables needs to be executed as root (I don't want to sudo for a password or set up a passwordless sudo user account), and Python scripts aren't allowed to run as setuid root. Hence I'm writing a C program whose sole function is to run as setuid root and pass (sanitized) parameters to iptables:
int return_val = system("iptables -A Parental_Timeblock -m time --weekdays Su,Mo,Tu,We,Th,Fr,Sa --timestart <sanitized argv params> --timestop <more sanitized argv params> -j DROP")
Haven't done C programming for decades. Would appreciate some hand-holding regarding the execl() calls. Thanks.
| aef0590010a2da84504ca01a03885214fd2c87a0718334aa10d91fec97b37a11 | ['ec310b8b82ca43c992050681a87a7d58'] | This is a regex question. In this particular case I'm using Vim to do the work, but I'd be interested in the general answer to the regex portion for other times I'm using other varieties of regex.
Consider the following example where I want to replace some arbitrary text string "ab" with some other text "cd", but only if it occurs between the words START and END:
Before:
ab ab ab START ab ab ab END ab ab ab
I would like this to become:
ab ab ab START cd cd cd END ab ab ab
There may be other words/text between the occurrences of the string "ab" which I want to replace. It is not known how many times the string "ab" appears before "START", between "START" and "END", and after "END". It might not appear at all.
I would prefer not to have break up each line at the START and END delimiters, do a global s/ab/cd/g on that line only, and then rejoin the lines. Is there a regex that will only match the "ab" between the delimiters?
|
5d2c0e23ebe58f9139908dc90f0c7751e08df0636bfa15482b1867d8b38f2721 | ['ec31e48db32648e8bf508a6d84589c6b'] | If the date you receive is different from the current culture you can use DateTime.Parse to convert to a correct DateTime variable.
As you are using ToString to convert a DateTime type to a formatted date string, your myBirthDate variable will become a String, thus the >= won't work as expected.
Here is a sample:
using System;
public class Example
{
public static void Main()
{
string[] dateStrings = {"2008-05-01T07:34:42-5:00",
"2008-05-01 7:34:42Z",
"Thu, 01 May 2008 07:34:42 GMT"};
foreach (string dateString in dateStrings)
{
DateTime convertedDate = DateTime.Parse(dateString);
Console.WriteLine("Converted {0} to {1} time {2}",
dateString,
convertedDate.Kind.ToString(),
convertedDate);
}
}
}
| 794333232db2eda63c89603b41cc2a8627ae6e009e9bee4df1329e60ed1c4a49 | ['ec31e48db32648e8bf508a6d84589c6b'] | I'm trying to configure Travis CI build for my Ruby on Rails project on GitHub, however the MySQL configuration is not working. What is wrong with my config?
.travis.yml
language: ruby
before_script:
- mysql -e 'create database simple_cms_test;'
rvm:
- 2.1
database.yml
default: &default
adapter: mysql2
encoding: utf8
pool: 5
socket: /var/run/mysqld/mysqld.sock
development:
<<: *default
database: simple_cms_development
username: simple_cms
password: xpto
test:
<<: *default
database: simple_cms_test
username: root
<PERSON> gives access denied for the database configuration.
"Mysql2<IP_ADDRESS>Error: Access denied for user 'root'@'localhost' (using password: YES)"
The repository is https://github.com/julianonunes/simple_cms
|
ba64f43ad5339edd97d010df9c2a1b5c2a4c8e1662cf59df3e143ee894f6267a | ['ec347a3fa8e3432082833a7b0f83fcef'] | I just tested your code and it works fine. I think it has more to do with your configuration.
You will get 0 steps if you havent added the client_secret to your res folder.
If you navigate to your console where you made your OAuth V2 token go here:
Where to download JSON client_secret
Then paste your client_secret inside your resource folder here:
Where to paste OAuth Key
If you still have issues with getting 0 steps, consider installing the Google Fit App and manually add steps that way. This way you can check if its an authentication problem or direct issue related to your data.
Hope this helps!
| 3e0cb4cc3b2da3e141709804a7dcab56f00d484afc9a92206e9901c2315def6d | ['ec347a3fa8e3432082833a7b0f83fcef'] | I am trying to create a function that receives an array and an object and returns a combination of the two like so.
fruits: [
{
name: apple,
seeds: ''
},
{
name: grape,
seeds: ''
},
{ name: banana,
seeds: ''
},
]
const seedData = {
apple: 'yes',
banana: 'yes',
grape: 'no',
}
setSeedData = (fruits, seedData) => {
return completedFruits
}
Wanted result is like so:
fruits: [
{
name: apple,
seeds: 'yes'
},
{
name: grape,
seeds: 'yes'
},
{
name: banana,
seeds: 'no'
},
]
My question is: How do I create the function setSeedData? De array returned should replace the current fruits array.
|
12cd6c2dc78cfb91744f58a13e52ef599ba9201f18e5d0e4acfa75e15a67deed | ['ec38a7cd88164316b519dcbdf672598a'] | I want to live stream a 360 video to my android app.
The main function of the app is to watch live 360 videos.
I tried using the YouTube API, but it does not work as it doesn´t render the video. I tried using the Google VRVideoView from the cardboard API. But it seems it can´t parse YouTube URI.
Is there any way I can do this? Or any alternative platform that supports 360 video steaming on mobile?
| dd1f824d31d3ddce4222349a6f8a9559ffc7f3f8d9fa3af76b0a43676ff7b320 | ['ec38a7cd88164316b519dcbdf672598a'] | So I found out what happened for anyone who has this sort of problem.
I had to Create a response to the request of method OPTION also which has in it's headers the allow headers method. Something like this
v1.OPTIONS("/users", OptionsUser) // POST
v1.OPTIONS("/users/:id", OptionsUser) // PUT, DELETE
func OptionsUser(c *gin.Context) {
c.Writer.Header().Set("Access-Control-Allow-Methods", "DELETE,POST, PUT")
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type")
c.Next()
}
extracted from: https://medium.com/@etiennerouzeaud/how-to-create-a-basic-restful-api-in-go-c8e032ba3181
Thing is: angular and ionic http basic method create a preflight of type OPTION before sending POST. I just had to handle it...
|
1f169c9a962f3b533a1f734c369d64f6c647d3343cb387f53408ed3968ce3250 | ['ec39c650dcf64eeaa215f980069c16d0'] | I'm a young math teacher who often deals with the problem of finding good sources of sets of exercises as inspiration for my own exercises sheets and exams. In the past I frequently visited ixl.com (example: Grad 9 maths practice) but are there better options? What sources (web, books...) do you like/use? I'm interested in finding as many types of problems to a specific topic as possible.
Example (Different types of problem to the topic "fractions")
addition of fractions
subtraction of fractions
division of fractions
multiplication of fractions
To be even more specific you could divide the skills mentioned above in something like "addition of algebraic fractions" and "addition of fractions with variables" and something like that.
| 860cc95cf4385da6095baeb3e2caa571ecc9656c2f14d7da4e003d8e56715a06 | ['ec39c650dcf64eeaa215f980069c16d0'] | I think your issue is around the following lines
StandardInput=tty-force
StandardOutput=inherit
StandardError=inherit
This means that the standard input takes in the input of /dev/console as there is now TTYPath specified in your service.
By setting standard output and standard error to inherit that means that they also take on the setting of standard input which in this case is /dev/console.
I'm not 100% on this but I imagine that is why you're seeing the output you're seeing. If you still need the input but don't want the output you should probably just have:
StandardInput=tty-force
Without the other two lines. If you're not actually using the Input though you can also get rid of that line.
|
6e96afc2a7ea0fe15fc78d03f71673006bf5aa622f728f8236be063eafed4de9 | ['ec41a3f02e67408282feaf4612025e50'] | 1; turn on developer ribbon
2; record copy selection, going to end of sheet, down another 2 rows all using 'relative refs'.
3; create a new macro to say something like this...
Dim I as integer
Set i = 0
Do
Call {macro recorded}
Set i = i + 1
Loop while i < 101
End
I have pretty much guessed the syntax, using a phone so no checking... Hopefully its enough to get you started.
| 7b97581f01c4f7957ae13579b8090d16ce10fd17c2332d31f2adb2e3bfbefc5c | ['ec41a3f02e67408282feaf4612025e50'] | I have a table which each row contain a time. The table should show the closest time of the day on top. For example, if the current time is 12:03 the first row on the table should be 12:00. Basically the table auto scroll depending on the time of the day.
I have a code that works fine when running in Visual Studio development environment (Cassini). The code also works in jsFiddle here, but when I install the code in the server or run it with IIS Express, the position always return 0. I do not understand why the jquery position doesn't work or return 0 when IIS or IIS express is used.
Below is the jquery code:
$(document).ready(function () {
var tableID = $('.dcBooking')[0].id; //get the id of table.
var layerID = $('#' + tableID).parent().closest('div').attr('id'); //get the id of the div created by .Net
var currentdate = new Date();
var hour = currentdate.getHours();
var min = currentdate.getMinutes();
var mod = min % 10;
min = (min - mod); //Rounded to the closest previous 10 minutes
var id = getID(hour, min);
var timeTag = $('#' + id);
$('#' + layerID).animate({ scrollTop: timeTag.position().top }, 'slow');
});
Example of HTML:
<div id="id1" style="overflow-x:visible;overflow-y:scroll;height:350px;position:relative;">
<table class="dcBooking">
<tr id="h08_00_0"><td>08:00</td><td>Joe</td></tr>
<tr id="h12_10_0"><td>12:10</td><td>John</td></tr>
:
:
<tr id="h17_00_0"><td>07_00</td><td>Anna</td></tr>
</table>
</div>
I have run out of ideas why the code return a position when run in Cassini or jsFiddle, but it doesn't when installed on the server or run in IIS express. I thought about security issue, but it runs on my computer with Cassini, but not with IIS express, so I think must be some IIS set-up, but I don't know where to look in IIS. Can anyone point me out what or where to look or have an idea what could be the reason of the problem?
|
d4b8bd530686b20be09307464a6a4910bd34567f3e62f41e3a8e24223b4b7484 | ['ec4f1fb2abf84360824948182ff6b740'] | I own a Samsung Galaxy S2 (Android version: 4.1.2) and I'm trying to deploy an application from Xamrin Studio. The result is: "Deployment Failed. Internal Error". In the log it says:
Mono.AndroidTools.InstallFailedException: Installation failed due to container error. This can be caused by lack of available space on the SD card or stale files left behind from previous installations.
I've checked the available space and i suppose it's not the problem - Empty SD card and 3GB free in the phone memory.
More things I tried:
Uncheck "Fast assembly deployment" - didn't work.
Tried to deploy an application using "Dot42", and it worked with no problems.
Change "Install location" to "internalOnly" - didn't work.
Any help would be much appreciated.
| 6158bff376de0c0f2a576f88b203380b1ff63e5a7312e1b9530f313d11290928 | ['ec4f1fb2abf84360824948182ff6b740'] | When connecting Samsung Galaxy S via USB to hyperterminal, I cannot retrieve any messages or send messages. The commands "AT", "AT+CMGF=1" work, and "AT+CMPI=?" return different memories available. But when I try to execute the following command: AT+CMPI="SM" (or any other memory) I get an error. In addition when I try AT+CMGS="..." it gives an error too. What can it be?
Thank you!
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.